From: Dan Carpenter <error27@gmail.com>
To: Yuan Can <yuancan@huawei.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 12:35:24 +0300 [thread overview]
Message-ID: <Y5Gv3Gz52ILDMpWg@kadam> (raw)
In-Reply-To: <20221208083859.122622-1-yuancan@huawei.com>
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;
regards,
dan carpenter
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2022-12-08 9:44 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 [this message]
2022-12-08 11:26 ` Yuan Can
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=Y5Gv3Gz52ILDMpWg@kadam \
--to=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 \
--cc=yuancan@huawei.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