* [PATCH v2] mtd: parsers: Fix potential memory leak in mtd_parser_tplink_safeloader_parse()
@ 2022-12-08 11:32 Yuan Can
2022-12-08 11:38 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Yuan Can @ 2022-12-08 11:32 UTC (permalink / raw)
To: miquel.raynal, richard, vigneshr, rafal, error27, linux-mtd; +Cc: yuancan
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 | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/parsers/tplink_safeloader.c b/drivers/mtd/parsers/tplink_safeloader.c
index f601e7bd8627..1c689dafca2a 100644
--- a/drivers/mtd/parsers/tplink_safeloader.c
+++ b/drivers/mtd/parsers/tplink_safeloader.c
@@ -91,7 +91,7 @@ static int mtd_parser_tplink_safeloader_parse(struct mtd_info *mtd,
buf = mtd_parser_tplink_safeloader_read_table(mtd);
if (!buf) {
err = -ENOENT;
- goto err_out;
+ goto err_free_parts;
}
for (idx = 0, offset = TPLINK_SAFELOADER_DATA_OFFSET;
@@ -118,6 +118,8 @@ static int mtd_parser_tplink_safeloader_parse(struct mtd_info *mtd,
err_free:
for (idx -= 1; idx >= 0; idx--)
kfree(parts[idx].name);
+err_free_parts:
+ kfree(parts);
err_out:
return err;
};
--
2.17.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] mtd: parsers: Fix potential memory leak in mtd_parser_tplink_safeloader_parse()
2022-12-08 11:32 [PATCH v2] mtd: parsers: Fix potential memory leak in mtd_parser_tplink_safeloader_parse() Yuan Can
@ 2022-12-08 11:38 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2022-12-08 11:38 UTC (permalink / raw)
To: Yuan Can; +Cc: miquel.raynal, richard, vigneshr, rafal, linux-mtd
On Thu, Dec 08, 2022 at 11:32:53AM +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>
Thanks!
Reviewed-by: Dan Carpenter <error27@gmail.com>
regards,
dan carpenter
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-08 11:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-08 11:32 [PATCH v2] mtd: parsers: Fix potential memory leak in mtd_parser_tplink_safeloader_parse() Yuan Can
2022-12-08 11:38 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).