Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751534AbdIJL5I (ORCPT ); Sun, 10 Sep 2017 07:57:08 -0400 Received: from mout.gmx.net ([212.227.15.19]:52887 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751413AbdIJL5G (ORCPT ); Sun, 10 Sep 2017 07:57:06 -0400 Subject: Re: [PATCH] btrfs: tests: Fix a memory leak in error handling path in 'run_test()' To: Christophe JAILLET , 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 References: <20170910111938.15201-1-christophe.jaillet@wanadoo.fr> From: Qu Wenruo Message-ID: <72f72ca7-8c48-5501-7835-ac619801cd34@gmx.com> Date: Sun, 10 Sep 2017 19:56:17 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170910111938.15201-1-christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:DnTegoETXIx2DhRwQxiyW0fQSyMPhXNXfppvIVAe0fIoS2+uZ3T YOnxIITvlkaTaZ13A6UNK7QPPrfLa4p5p5zjtSqSI5kRsxlYehO8aCW00Qlj97OQJbQhV4/ FQ8KgR3fq0cmwzZxBqQlC0tvF9fBsDmpg7j90SpbQIAdctJOkWeWRKo5GARaVRvjTRHAO8w NOZY9nZd2rZqzncIDsoEw== X-UI-Out-Filterresults: notjunk:1;V01:K0:fVF3vijnHPk=:IDQ0yem1bQL9bi/s7OxzAv TDdSZYX/xhbl6s/i5NGwyp7KLp9R6Do3UrTSGA2lC1nfMCUg3nI6OpSJziuqKMenWjzKprMNm JKZQ6XUtxHs08QuzIyTt8WTQO2LqRC23FslE8g0koIISRnEj09E5VZ81U7QnqjNYZ8j01WlIx PD+Mg+6BHWf09yE+M2sjap2XRWJYsX6krKUEXKPxc1hHyVGk6LYT9koh8fbqvps9ixsspUGxi JQfF+Frme3J5MtUgNtk7TIv2JVr6Y3qCFMgTjmGGqmYGPZ1foYSDa96Emla3Ue1bA8j91iBVA yse+moIOsLHKQPzDiMGorP0VdFsCjPqv27IK8otDsxy0KpfUhtdkUOPaEZ9Bd5VYdmY22IDu6 eKlnvu8aSZVu3w5GUCnJ7ONJBadouCQTLI5qWDDEX+C28YW9H0cPbHYr7KCulMbkzBbcHEq53 VrH0yGtfEBC9mQX32TpPhHrllnmAcf92Z6pKCU7LmOpXYyRzTJUgYByO1AWSvX0VB/uVQakjp e+tz8AwuV2mMsvz3CmsjsoIpIYVRe/jTEQWlXWjtA9ly5eSMX3tZ3SZZvsWyAeq3miPwwxm0U fZOrMFL6mVv878CLGexBvhbi7LwKaC+PntS7aIo8aWIiDnThx+GVIcd9GltpVwMJGRAV+eUnl b0XMUUGrrRB3lVa570KnWZHND/OcCHrwHxip4sJXIvW4acZlTuAKGt9fjA5xCDF9xIVfLEOyh 9v2Z+zePZqZDV3q8QgCnfsEHe1xZExsQr6VNDTfJFU2eU/ALvRzBeH6Iyvb9e5HhpX5mCJyuO l0sM1M2RkkjjYuulRxozRPyfMbvOHd8/tr59A2EkE1xgF7UaIU= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1084 Lines: 34 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 Reviewed-by: Qu Wenruo 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); >