Re: [PATCH v2] btrfs: Fix passing 0 to ERR_PTR in btrfs_search_dir_index_item()

From: David Sterba
Date: Tue Oct 22 2024 - 09:48:35 EST


On Tue, Oct 22, 2024 at 05:52:08PM +0800, Yue Haibing wrote:
> 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 fix
> 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")
> Signed-off-by: Yue Haibing <yuehaibing@xxxxxxxxxx>
> ---
> v2: return ERR_PTR(-ENOENT) while ret >= 0

Reviewed-by: David Sterba <dsterba@xxxxxxxx>

Added to for-next, thanks.