Skip to content

Commit 2073ae3

Browse files
committed
mtd: rawnand: mtk: Fix init error path
Reviewing a series converting the for_each_chil_of_node() loops into their _scoped variants made me realize there was no cleanup of the already registered NAND devices upon error which may leak memory on systems with more than a chip when this error occurs. We should call the _nand_chips_cleanup() function when this happens. Fixes: 1d6b1e4 ("mtd: mediatek: driver for MTK Smart Device") Signed-off-by: Miquel Raynal <[email protected]> Reviewed-by: Pratyush Yadav <[email protected]> Reviewed-by: Matthias Brugger <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 81cb3be commit 2073ae3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/mtd/nand/raw/mtk_nand.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,8 +1453,10 @@ static int mtk_nfc_nand_chips_init(struct device *dev, struct mtk_nfc *nfc)
14531453

14541454
for_each_child_of_node_scoped(np, nand_np) {
14551455
ret = mtk_nfc_nand_chip_init(dev, nfc, nand_np);
1456-
if (ret)
1456+
if (ret) {
1457+
mtk_nfc_nand_chips_cleanup(nfc);
14571458
return ret;
1459+
}
14581460
}
14591461

14601462
return 0;

0 commit comments

Comments
 (0)