]> git.hungrycats.org Git - linux/commit
btrfs: fix passing 0 to ERR_PTR in btrfs_search_dir_index_item()
authorYue Haibing <yuehaibing@huawei.com>
Tue, 22 Oct 2024 09:52:08 +0000 (17:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Nov 2024 01:02:40 +0000 (02:02 +0100)
commit2cbc7bd968f31b506f91cf16c45c72440b0b948e
treee509947113dde788d2fa408cfe5aec4b14d181c0
parent299903b1205e3224fd3d2f18630507132704d4b6
btrfs: fix passing 0 to ERR_PTR in btrfs_search_dir_index_item()

commit 75f49c3dc7b7423d3734f2e4dabe3dac8d064338 upstream.

The ret may be zero in btrfs_search_dir_index_item() and should not
passed to ERR_PTR(). Now btrfs_unlink_subvol() is the only caller to
this, reconstructed it to check ERR_PTR(-ENOENT) while ret >= 0.

This fixes smatch warnings:

fs/btrfs/dir-item.c:353
  btrfs_search_dir_index_item() warn: passing zero to 'ERR_PTR'

Fixes: 9dcbe16fccbb ("btrfs: use btrfs_for_each_slot in btrfs_search_dir_index_item")
CC: stable@vger.kernel.org # 6.1+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/dir-item.c
fs/btrfs/inode.c