Re: [PATCH] fs: btrfs: fix possible memory leaks in btrfs_get_dev_args_from_path()
From: David Sterba
Date: Wed Aug 17 2022 - 10:48:15 EST
On Mon, Aug 15, 2022 at 11:16:06PM +0800, Zixuan Fu wrote:
> In btrfs_get_dev_args_from_path(), btrfs_get_bdev_and_sb() can fail if the
> path is invalid. In this case, btrfs_get_dev_args_from_path() returns
> directly without freeing args->uuid and args->fsid allocated before, which
> causes memory leaks.
>
> To fix these possible leaks, when btrfs_get_bdev_and_sb() fails,
> btrfs_put_dev_args_from_path() is called to clean up the memory.
>
> Fixes: faa775c41d655 ("btrfs: add a btrfs_get_dev_args_from_path helper")
> Reported-by: TOTE Robot <oslab@xxxxxxxxxxxxxxx>
> Signed-off-by: Zixuan Fu <r33s3n6@xxxxxxxxx>
Added to misc-next, thanks.