Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: parsers: Fix potential memory leak in mtd_parser_tplink_safeloader_parse()
@ 2022-12-08  8:38 Yuan Can
  2022-12-08  9:35 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Yuan Can @ 2022-12-08  8:38 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 | 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:
 	return err;
 };
-- 
2.17.1


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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-08 11:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox