Skip to content

Commit 47bf225

Browse files
fdmananakdave
authored andcommitted
btrfs: fix silent failure when deleting root reference
At btrfs_del_root_ref(), if btrfs_search_slot() returns an error, we end up returning from the function with a value of 0 (success). This happens because the function returns the value stored in the variable 'err', which is 0, while the error value we got from btrfs_search_slot() is stored in the 'ret' variable. So fix it by setting 'err' with the error value. Fixes: 8289ed9 ("btrfs: replace the BUG_ON in btrfs_del_root_ref with proper error handling") CC: stable@vger.kernel.org # 5.16+ Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent ced8ecf commit 47bf225

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/btrfs/root-tree.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,10 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans, u64 root_id,
349349
key.offset = ref_id;
350350
again:
351351
ret = btrfs_search_slot(trans, tree_root, &key, path, -1, 1);
352-
if (ret < 0)
352+
if (ret < 0) {
353+
err = ret;
353354
goto out;
354-
if (ret == 0) {
355+
} else if (ret == 0) {
355356
leaf = path->nodes[0];
356357
ref = btrfs_item_ptr(leaf, path->slots[0],
357358
struct btrfs_root_ref);

0 commit comments

Comments
 (0)