Skip to content

Commit 6b37037

Browse files
name2965Kent Overstreet
authored andcommitted
bcachefs: fix incorrect pointer check in __bch2_subvolume_delete()
For some unknown reason, checks on struct bkey_s_c_snapshot and struct bkey_s_c_snapshot_tree pointers are missing. Therefore, I think it would be appropriate to fix the incorrect pointer checking through this patch. Fixes: 4bd06f0 ("bcachefs: Fixes for snapshot_tree.master_subvol") Signed-off-by: Jeongjun Park <aha310510@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent fdfd0ad commit 6b37037

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/bcachefs/subvolume.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static int __bch2_subvolume_delete(struct btree_trans *trans, u32 subvolid)
428428
bch2_bkey_get_iter_typed(trans, &snapshot_iter,
429429
BTREE_ID_snapshots, POS(0, snapid),
430430
0, snapshot);
431-
ret = bkey_err(subvol);
431+
ret = bkey_err(snapshot);
432432
bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), trans->c,
433433
"missing snapshot %u", snapid);
434434
if (ret)
@@ -440,6 +440,11 @@ static int __bch2_subvolume_delete(struct btree_trans *trans, u32 subvolid)
440440
bch2_bkey_get_iter_typed(trans, &snapshot_tree_iter,
441441
BTREE_ID_snapshot_trees, POS(0, treeid),
442442
0, snapshot_tree);
443+
ret = bkey_err(snapshot_tree);
444+
bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), trans->c,
445+
"missing snapshot tree %u", treeid);
446+
if (ret)
447+
goto err;
443448

444449
if (le32_to_cpu(snapshot_tree.v->master_subvol) == subvolid) {
445450
struct bkey_i_snapshot_tree *snapshot_tree_mut =

0 commit comments

Comments
 (0)