bcachefs: fix NULL bch_dev deref when checking bucket_gens keys
authorBrian Foster <bfoster@redhat.com>
Tue, 18 Apr 2023 17:05:47 +0000 (13:05 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:00 +0000 (17:10 -0400)
commit251babb55d53d79bba9568d6516fd11128c34606
treef9ef72f6ae359ad98b01003ed8559d0243cf79c6
parentbf98ee10d45af8e97c0802e39cc77ee607072633
bcachefs: fix NULL bch_dev deref when checking bucket_gens keys

fsck removes bucket_gens keys for devices that do not exist in the
volume (i.e., if the device was removed). In 'fsck -n' mode, the
associated fsck_err_on() wrapper returns false to skip the key
removal. This proceeds on to the rest of the function, which
eventually segfaults on a NULL bch_dev because the device does not
exist.

Update bch2_check_bucket_gens_key() to skip out of the rest of the
function when the associated device does not exist, regardless of
running fsck in check or repair mode.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_background.c