From: Josef Bacik Date: Fri, 5 Nov 2021 20:45:34 +0000 (-0400) Subject: btrfs: remove BUG_ON() in find_parent_nodes() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a8dcf313882539edca8eb0f4043269de9c3722f0;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git btrfs: remove BUG_ON() in find_parent_nodes() [ Upstream commit fcba0120edf88328524a4878d1d6f4ad39f2ec81 ] We search for an extent entry with .offset = -1, which shouldn't be a thing, but corruption happens. Add an ASSERT() for the developers, return -EUCLEAN for mortals. Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 1cf75d1032e1..f2c2ac3343ba 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1163,7 +1163,12 @@ again: ret = btrfs_search_slot(trans, fs_info->extent_root, &key, path, 0, 0); if (ret < 0) goto out; - BUG_ON(ret == 0); + if (ret == 0) { + /* This shouldn't happen, indicates a bug or fs corruption. */ + ASSERT(ret != 0); + ret = -EUCLEAN; + goto out; + } #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS if (trans && likely(trans->type != __TRANS_DUMMY) &&