]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: fix memory leak of path on error return path
authorColin Ian King <colin.king@canonical.com>
Fri, 5 Jul 2019 07:26:24 +0000 (08:26 +0100)
committerDavid Sterba <dsterba@suse.com>
Fri, 5 Jul 2019 16:47:57 +0000 (18:47 +0200)
commitf1657ffac40dae5ba9e3615ca54716bcf78c397c
tree59aec3f4273813834a2259005c104c1ec92ff919
parent420b54ae6bc13c69f4ee71f832250f5edf8d738f
btrfs: fix memory leak of path on error return path

Currently if the allocation of roots or tmp_ulist fails the error handling
does not free up the allocation of path causing a memory leak. Fix this and
other similar leaks by moving the call of btrfs_free_path from label out
to label out_free_ulist.

Kudos to David Sterba for spotting the issue in my original fix and suggesting
the correct way to fix the leak and Anand Jain for spotting a double free
issue.

Addresses-Coverity: ("Resource leak")
Fixes: 782f5fcf272f ("btrfs: fiemap: preallocate ulists for btrfs_check_shared")
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c