]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: remove pointless and double ulist frees in error paths of qgroup tests
authorFilipe Manana <fdmanana@suse.com>
Tue, 1 Nov 2022 16:15:40 +0000 (16:15 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Nov 2022 16:45:40 +0000 (17:45 +0100)
commitce75e9085988e51dbf2f57fd7c49aa4457fa892e
treeb13e41c4a45a4c81736e6e06e1f7e67d21f98e9d
parent16743c4bf3ef433cdd9babcd4d627b3387ad947d
btrfs: remove pointless and double ulist frees in error paths of qgroup tests

[ Upstream commit d0ea17aec12ea0f7b9d2ed727d8ef8169d1e7699 ]

Several places in the qgroup self tests follow the pattern of freeing the
ulist pointer they passed to btrfs_find_all_roots() if the call to that
function returned an error. That is pointless because that function always
frees the ulist in case it returns an error.

Also In some places like at test_multiple_refs(), after a call to
btrfs_qgroup_account_extent() we also leave "old_roots" and "new_roots"
pointing to ulists that were freed, because btrfs_qgroup_account_extent()
has freed those ulists, and if after that the next call to
btrfs_find_all_roots() fails, we call ulist_free() on the "old_roots"
ulist again, resulting in a double free.

So remove those calls to reduce the code size and avoid double ulist
free in case of an error.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/tests/qgroup-tests.c