Skip to content
Commit 9ea0106a authored by Zixuan Fu's avatar Zixuan Fu Committed by David Sterba
Browse files

btrfs: fix possible memory leak in btrfs_get_dev_args_from_path()



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 leak.

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.

Reported-by: default avatarTOTE Robot <oslab@tsinghua.edu.cn>
Fixes: faa775c4 ("btrfs: add a btrfs_get_dev_args_from_path helper")
CC: stable@vger.kernel.org # 5.16
Reviewed-by: default avatarBoris Burkov <boris@bur.io>
Signed-off-by: default avatarZixuan Fu <r33s3n6@gmail.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent b5111127
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment