[PATCH] fs: btrfs: Prevent error pointer dereference in list_subvolums()

Qu Wenruo wqu at suse.com
Tue Aug 1 11:06:55 CEST 2023



On 2023/7/26 14:59, Dan Carpenter wrote:
> If btrfs_read_fs_root() fails with -ENOENT, then we go to the next
> entry.  Fine.  But if it fails for a different reason then we need
> to clean up and return an error code.  In the current code it
> doesn't clean up but instead dereferences "root" and crashes.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter at linaro.org>

Reviewed-by: Qu Wenruo <wqu at suse.com>

> ---
> I didn't CC the btrfs mailing list.  Perhaps, I should have?

This patch is fine. The function is specific to U-boot, and not utilized 
by kernel/btrfs-progs.

Thanks,
Qu

> 
>   fs/btrfs/subvolume.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/fs/btrfs/subvolume.c b/fs/btrfs/subvolume.c
> index d446e7a2c418..68ca7e48e48e 100644
> --- a/fs/btrfs/subvolume.c
> +++ b/fs/btrfs/subvolume.c
> @@ -199,6 +199,7 @@ static int list_subvolums(struct btrfs_fs_info *fs_info)
>   			ret = PTR_ERR(root);
>   			if (ret == -ENOENT)
>   				goto next;
> +			goto out;
>   		}
>   		ret = list_one_subvol(root, result);
>   		if (ret < 0)


More information about the U-Boot mailing list