diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-10-28 01:40:20 +0100 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-11-07 22:48:17 +0100 |
commit | fd00045f383f51b66a7a46084a0e92b8de563157 (patch) | |
tree | d905d0bcbe2fd8322876970757cf46fd81ba6549 /fs/bcachefs/io_write.c | |
parent | Linux 6.12-rc6 (diff) | |
download | linux-fd00045f383f51b66a7a46084a0e92b8de563157.tar.xz linux-fd00045f383f51b66a7a46084a0e92b8de563157.zip |
bcachefs: Fix null ptr deref in bucket_gen_get()
bucket_gen() checks if we're lookup up a valid bucket and returns NULL
otherwise, but bucket_gen_get() was failing to check; other callers were
correct.
Also do a bit of cleanup on callers.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/io_write.c')
-rw-r--r-- | fs/bcachefs/io_write.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/fs/bcachefs/io_write.c b/fs/bcachefs/io_write.c index 8609e25e450f..96720adcfee0 100644 --- a/fs/bcachefs/io_write.c +++ b/fs/bcachefs/io_write.c @@ -1300,11 +1300,8 @@ retry: bucket_to_u64(i->b), BUCKET_NOCOW_LOCK_UPDATE); - rcu_read_lock(); - u8 *gen = bucket_gen(ca, i->b.offset); - stale = !gen ? -1 : gen_after(*gen, i->gen); - rcu_read_unlock(); - + int gen = bucket_gen_get(ca, i->b.offset); + stale = gen < 0 ? gen : gen_after(gen, i->gen); if (unlikely(stale)) { stale_at = i; goto err_bucket_stale; |