]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: fix possible leak in btrfs_ioctl_balance()
authorChristian Engelmayer <cengelma@gmx.at>
Tue, 20 Oct 2015 22:50:06 +0000 (00:50 +0200)
committerChris Mason <clm@fb.com>
Thu, 22 Oct 2015 01:10:02 +0000 (18:10 -0700)
commit01d87a0e52590d0e032c026ed957cd4ed591db3d
treef89024b26a6294f420e5957c191f53cb778d6d62
parent5ab0272640c1c1a211acf3fe99396ab27a534e78
btrfs: fix possible leak in btrfs_ioctl_balance()

Commit c2174b481063 ("btrfs: check unsupported filters in balance
arguments") adds a jump to exit label out_bargs in case the argument
check fails. At this point in addition to the bargs memory, the
memory for struct btrfs_balance_control has already been allocated.
Ownership of bctl is passed to btrfs_balance() in the good case,
thus the memory is not freed due to the introduced jump. Make sure
that the memory gets freed in any case as necessary. Detected by
Coverity CID 1328378.

Signed-off-by: Christian Engelmayer <cengelma@gmx.at>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/ioctl.c