]> git.ipfire.org Git - people/arne_f/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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 07:48:17 +0000 (09:48 +0200)
commit547cc243f66b9fae46530f67f7bc7c6c5b022747
treea857a0fa3206f6d4409b588d62dbd4365a1968f4
parent10742034076daea73acc17779e8f234060e03489
btrfs: fix memory leaks after failure to lookup checksums during inode logging

commit 4f26433e9b3eb7a55ed70d8f882ae9cd48ba448b upstream.

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: 3650860b90cc2a ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/tree-log.c