]> www.infradead.org Git - users/hch/misc.git/commitdiff
mtd: rawnand: nuvoton: Fix an error handling path in ma35_nand_chips_init()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Wed, 30 Jul 2025 19:47:46 +0000 (21:47 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 28 Aug 2025 12:23:05 +0000 (14:23 +0200)
If a ma35_nand_chip_init() call fails, then a reference to 'nand_np' still
needs to be released.

Use for_each_child_of_node_scoped() to fix the issue.

Fixes: 5abb5d414d55 ("mtd: rawnand: nuvoton: add new driver for the Nuvoton MA35 SoC")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/nuvoton-ma35d1-nand-controller.c

index c23b537948d5e60098b8c8a810256ee1be267491..1a285cd8fad62aff9439304cecf9b7f14676eb25 100644 (file)
@@ -935,10 +935,10 @@ static void ma35_chips_cleanup(struct ma35_nand_info *nand)
 
 static int ma35_nand_chips_init(struct device *dev, struct ma35_nand_info *nand)
 {
-       struct device_node *np = dev->of_node, *nand_np;
+       struct device_node *np = dev->of_node;
        int ret;
 
-       for_each_child_of_node(np, nand_np) {
+       for_each_child_of_node_scoped(np, nand_np) {
                ret = ma35_nand_chip_init(dev, nand, nand_np);
                if (ret) {
                        ma35_chips_cleanup(nand);