* [PATCH] btrfs: tests: Fix a memory leak in error handling path in 'run_test()'
@ 2017-09-10 11:19 Christophe JAILLET
2017-09-10 11:56 ` Qu Wenruo
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2017-09-10 11:19 UTC (permalink / raw)
To: clm, jbacik, dsterba, nborisov, jeffm, osandov
Cc: linux-btrfs, linux-kernel, kernel-janitors, Christophe JAILLET
If 'btrfs_alloc_path()' fails, we must free the resourses already
allocated, as done in the other error handling paths in this function.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
fs/btrfs/tests/free-space-tree-tests.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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);
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs: tests: Fix a memory leak in error handling path in 'run_test()'
2017-09-10 11:19 [PATCH] btrfs: tests: Fix a memory leak in error handling path in 'run_test()' Christophe JAILLET
@ 2017-09-10 11:56 ` Qu Wenruo
0 siblings, 0 replies; 2+ messages in thread
From: Qu Wenruo @ 2017-09-10 11:56 UTC (permalink / raw)
To: Christophe JAILLET, clm, jbacik, dsterba, nborisov, jeffm, osandov
Cc: linux-btrfs, linux-kernel, kernel-janitors
On 2017年09月10日 19:19, Christophe JAILLET wrote:
> If 'btrfs_alloc_path()' fails, we must free the resourses already
> allocated, as done in the other error handling paths in this function.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
BTW, I also checked all btrfs_alloc_path() in self tests, not such leak
remaining.
Thanks,
Qu
> ---
> fs/btrfs/tests/free-space-tree-tests.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> 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);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-10 11:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-10 11:19 [PATCH] btrfs: tests: Fix a memory leak in error handling path in 'run_test()' Christophe JAILLET
2017-09-10 11:56 ` Qu Wenruo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).