]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: fix memory leaks after failure to lookup checksums during inode logging
authorFilipe Manana <fdmanana@suse.com>
Wed, 29 Jul 2020 09:17:50 +0000 (10:17 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 10 Aug 2020 16:58:30 +0000 (18:58 +0200)
commit422c781d59ecf1c8e927929a4a01f2825353c399
tree7f380a62ef3fb328e06ae5afce8e3e6946bdd017
parent5e6d02bc9d0c32eeaea71129cbc4fe995542dd27
btrfs: fix memory leaks after failure to lookup checksums during inode logging

While logging an inode, at copy_items(), if we fail to lookup the checksums
for an extent we release the destination path, free the ins_data array and
then return immediately. However a previous iteration of the for loop may
have added checksums to the ordered_sums list, in which case we leak the
memory used by them.

So fix this by making sure we iterate the ordered_sums list and free all
its checksums before returning.

Fixes: 6007639ef803ff ("Btrfs: remove almost all of the BUG()'s from tree-log.c")
CC: stable@vger.kernel.org # 4.4+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/tree-log.c