Skip to content

Commit 4f6d43f

Browse files
fdmananaSasha Levin
authored andcommitted
btrfs: exit after state insertion failure at btrfs_convert_extent_bit()
[ Upstream commit 3bf179e ] If insert_state() state failed it returns an error pointer and we call extent_io_tree_panic() which will trigger a BUG() call. However if CONFIG_BUG is disabled, which is an uncommon and exotic scenario, then we fallthrough and call cache_state() which will dereference the error pointer, resulting in an invalid memory access. So jump to the 'out' label after calling extent_io_tree_panic(), it also makes the code more clear besides dealing with the exotic scenario where CONFIG_BUG is disabled. Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0f1f998 commit 4f6d43f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/btrfs/extent-io-tree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,7 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
14561456
if (IS_ERR(inserted_state)) {
14571457
ret = PTR_ERR(inserted_state);
14581458
extent_io_tree_panic(tree, prealloc, "insert", ret);
1459+
goto out;
14591460
}
14601461
cache_state(inserted_state, cached_state);
14611462
if (inserted_state == prealloc)

0 commit comments

Comments
 (0)