bcachefs: fix possible null-ptr-deref in __bch2_ec_stripe_head_get()
authorGaosheng Cui <cuigaosheng1@huawei.com>
Sat, 26 Oct 2024 10:26:58 +0000 (18:26 +0800)
committerKent Overstreet <kent.overstreet@linux.dev>
Tue, 29 Oct 2024 10:34:10 +0000 (06:34 -0400)
commitca959e328b2243687aa0b95de01414d13e4f3ade
treea8fdb159b4254f9ad25c5069f9efcb25e65d58de
parent778ac324ccfad7b941bba604118e38a19800657b
bcachefs: fix possible null-ptr-deref in __bch2_ec_stripe_head_get()

The function ec_new_stripe_head_alloc() returns nullptr if kzalloc()
fails. It is crucial to verify its return value before dereferencing
it to avoid a potential nullptr dereference.

Fixes: 035d72f72c91 ("bcachefs: bch2_ec_stripe_head_get() now checks for change in rw devices")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/ec.c
fs/bcachefs/errcode.h