Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yuan Can <yuancan@huawei.com>
To: Dan Carpenter <error27@gmail.com>
Cc: <miquel.raynal@bootlin.com>, <richard@nod.at>, <vigneshr@ti.com>,
	<rafal@milecki.pl>, <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH] mtd: parsers: Fix potential memory leak in mtd_parser_tplink_safeloader_parse()
Date: Thu, 8 Dec 2022 19:26:15 +0800	[thread overview]
Message-ID: <4c39f759-553f-bd73-46e8-384d52be450c@huawei.com> (raw)
In-Reply-To: <Y5Gv3Gz52ILDMpWg@kadam>


在 2022/12/8 17:35, Dan Carpenter 写道:
> On Thu, Dec 08, 2022 at 08:38:59AM +0000, Yuan Can wrote:
>> The parts needs to be freed with all its elements, otherwise it will be
>> leaked.
>>
>> Fixes: 00a3588084be ("mtd: parsers: add TP-Link SafeLoader partitions table parser")
>> Signed-off-by: Yuan Can <yuancan@huawei.com>
>> ---
>>   drivers/mtd/parsers/tplink_safeloader.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/mtd/parsers/tplink_safeloader.c b/drivers/mtd/parsers/tplink_safeloader.c
>> index f601e7bd8627..860339461905 100644
>> --- a/drivers/mtd/parsers/tplink_safeloader.c
>> +++ b/drivers/mtd/parsers/tplink_safeloader.c
>> @@ -118,6 +118,7 @@ static int mtd_parser_tplink_safeloader_parse(struct mtd_info *mtd,
>>   err_free:
>>   	for (idx -= 1; idx >= 0; idx--)
>>   		kfree(parts[idx].name);
>> +	kfree(parts);
>>   err_out:
> This still leaves a leak if mtd_parser_tplink_safeloader_read_table()
> fails.  Create a new label and update the goto.
>
> err_free:
>   	for (idx -= 1; idx >= 0; idx--)
>   		kfree(parts[idx].name);
> err_free_parts:
> 	kfree(parts);
> err_out:
> 	return err;
Thanks for pointing out this! will be fixed in the next version.

-- 
Best regards,
Yuan Can


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2022-12-08 11:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-08  8:38 [PATCH] mtd: parsers: Fix potential memory leak in mtd_parser_tplink_safeloader_parse() Yuan Can
2022-12-08  9:35 ` Dan Carpenter
2022-12-08 11:26   ` Yuan Can [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4c39f759-553f-bd73-46e8-384d52be450c@huawei.com \
    --to=yuancan@huawei.com \
    --cc=error27@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=rafal@milecki.pl \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox