From: Kent Overstreet Date: Wed, 2 Apr 2025 16:48:23 +0000 (-0400) Subject: bcachefs: Fix null ptr deref in invalidate_one_bucket() X-Git-Tag: nvme-6.15-2025-04-10~18^2~2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=39ebd74864f5c4f7d44f1fe026c71a270631186b;p=nvme.git bcachefs: Fix null ptr deref in invalidate_one_bucket() bch2_backpointer_get_key() returns bkey_s_c_null when the target isn't found. backpointer_get_key() flags the error, so there's nothing else to do here - just skip it and move on. Link: https://github.com/koverstreet/bcachefs/issues/847 Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 6b6c2521c11f..94ea9e49aec4 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -2084,6 +2084,9 @@ static int invalidate_one_bp(struct btree_trans *trans, if (ret) return ret; + if (!extent_k.k) + return 0; + struct bkey_i *n = bch2_bkey_make_mut(trans, &extent_iter, &extent_k, BTREE_UPDATE_internal_snapshot_node);