diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 6b8824de2abb2..0073182d4e689 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1160,7 +1160,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) &&