]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: remove BUG_ON() in find_parent_nodes()
authorJosef Bacik <josef@toxicpanda.com>
Fri, 5 Nov 2021 20:45:34 +0000 (16:45 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 07:46:18 +0000 (08:46 +0100)
[ 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 <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/backref.c

index 228bfa19b745d6877f2f0ebb16afaab7e674ed79..c59a13a53b1cc10b040be167017ecd5699138785 100644 (file)
@@ -975,7 +975,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) &&