From: Christophe JAILLET Date: Sun, 10 Sep 2017 11:19:38 +0000 (+0200) Subject: btrfs: tests: Fix a memory leak in error handling path in 'run_test()' X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=9ca2e97fa3c3216200afe35a3b111ec51cc796d2;p=openwrt%2Fstaging%2Fblogic.git btrfs: tests: Fix a memory leak in error handling path in 'run_test()' If 'btrfs_alloc_path()' fails, we must free the resources already allocated, as done in the other error handling paths in this function. Signed-off-by: Christophe JAILLET Reviewed-by: Qu Wenruo Signed-off-by: David Sterba --- diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c index 1458bb0ea124..8444a018cca2 100644 --- a/fs/btrfs/tests/free-space-tree-tests.c +++ b/fs/btrfs/tests/free-space-tree-tests.c @@ -500,7 +500,8 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize, path = btrfs_alloc_path(); if (!path) { test_msg("Couldn't allocate path\n"); - return -ENOMEM; + ret = -ENOMEM; + goto out; } ret = add_block_group_free_space(&trans, root->fs_info, cache);