Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751482AbdIJL3o (ORCPT ); Sun, 10 Sep 2017 07:29:44 -0400 Received: from smtp04.smtpout.orange.fr ([80.12.242.126]:33122 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751413AbdIJL3m (ORCPT ); Sun, 10 Sep 2017 07:29:42 -0400 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 10 Sep 2017 13:29:41 +0200 X-ME-IP: 86.196.182.67 From: Christophe JAILLET To: clm@fb.com, jbacik@fb.com, dsterba@suse.com, nborisov@suse.com, jeffm@suse.com, osandov@fb.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] btrfs: tests: Fix a memory leak in error handling path in 'run_test()' Date: Sun, 10 Sep 2017 13:19:38 +0200 Message-Id: <20170910111938.15201-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 838 Lines: 24 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 --- 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