]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bcachefs: Fix null ptr deref in bch2_snapshot_tree_oldest_subvol()
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 18 Apr 2025 02:38:14 +0000 (22:38 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 20 Apr 2025 23:41:38 +0000 (19:41 -0400)
Reported-by: syzbot+baee8591f336cab0958b@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/snapshot.c

index b7de29aed83917b5712261b076f77600a6373689..fec569c7deb1c7bf703161f42dd5d8db459e2c81 100644 (file)
@@ -396,7 +396,7 @@ u32 bch2_snapshot_tree_oldest_subvol(struct bch_fs *c, u32 snapshot_root)
        u32 subvol = 0, s;
 
        rcu_read_lock();
-       while (id) {
+       while (id && bch2_snapshot_exists(c, id)) {
                s = snapshot_t(c, id)->subvol;
 
                if (s && (!subvol || s < subvol))