From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oxrO8-0001pK-3T for mharc-grub-devel@gnu.org; Wed, 23 Nov 2022 10:10:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxrO5-0001pB-Je for grub-devel@gnu.org; Wed, 23 Nov 2022 10:10:09 -0500 Received: from dibed.net-space.pl ([84.10.22.86]) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_3DES_EDE_CBC_SHA1:192) (Exim 4.90_1) (envelope-from ) id 1oxrO3-00032l-3g for grub-devel@gnu.org; Wed, 23 Nov 2022 10:10:09 -0500 Received: from router-fw.i.net-space.pl ([192.168.52.1]:58334 "EHLO tomti.i.net-space.pl") by router-fw-old.i.net-space.pl with ESMTP id S2160546AbiKWPKE (ORCPT ); Wed, 23 Nov 2022 16:10:04 +0100 X-Comment: RFC 2476 MSA function at dibed.net-space.pl logged sender identity as: dkiper Date: Wed, 23 Nov 2022 16:10:02 +0100 From: Daniel Kiper To: fengtao40@huawei.com Cc: grub-devel@gnu.org, yanan@huawei.com, zhaowei23@huawei.com Subject: Re: [PATCH 3/9] fs/minix: Fix memory leak in grub_minix_lookup_symlink Message-ID: <20221123151002.s5ibg45ik4prdg63@tomti.i.net-space.pl> References: <20221119103946.657744-1-fengtao40@huawei.com> <20221119103946.657744-4-fengtao40@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221119103946.657744-4-fengtao40@huawei.com> User-Agent: NeoMutt/20170113 (1.7.2) Received-SPF: pass client-ip=84.10.22.86; envelope-from=dkiper@net-space.pl; helo=dibed.net-space.pl X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Nov 2022 15:10:09 -0000 On Sat, Nov 19, 2022 at 06:39:40PM +0800, t.feng via Grub-devel wrote: > Fix memory leaks in grub_minix_lookup_symlink. > > Fixes: a07e6ad01(Remove variable length arrays) > > Signed-off-by: "t.feng" > --- > grub-core/fs/minix.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/grub-core/fs/minix.c b/grub-core/fs/minix.c > index 953df1191..2176b6e93 100644 > --- a/grub-core/fs/minix.c > +++ b/grub-core/fs/minix.c > @@ -374,7 +374,10 @@ grub_minix_lookup_symlink (struct grub_minix_data *data, grub_minix_ino_t ino) > if (!symlink) > return grub_errno; > if (grub_minix_read_file (data, 0, 0, 0, sz, symlink) < 0) > - return grub_errno; > + { > + grub_free (symlink); > + return grub_errno; > + } > > symlink[sz] = '\0'; > > @@ -384,10 +387,14 @@ grub_minix_lookup_symlink (struct grub_minix_data *data, grub_minix_ino_t ino) > > /* Now load in the old inode. */ > if (grub_minix_read_inode (data, ino)) > - return grub_errno; > + { > + grub_free (symlink); > + return grub_errno; > + } > > grub_minix_find_file (data, symlink); > This could be made simpler. Just add a label "fail" here and grub_free(symlink) underneath. Then add "goto fail" above. > + grub_free (symlink); > return grub_errno; > } Daniel