]> www.infradead.org Git - users/hch/misc.git/commitdiff
mtd: rawnand: atmel: Fix error handling path in atmel_nand_controller_add_nands
authorErick Karanja <karanja99erick@gmail.com>
Mon, 22 Sep 2025 11:07:27 +0000 (14:07 +0300)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 29 Sep 2025 15:55:22 +0000 (17:55 +0200)
In case of a jump to the  err label due to atmel_nand_create() or
atmel_nand_controller_add_nand() failure, the reference to nand_np
need to be released

Use for_each_child_of_node_scoped() to fix the issue.

Fixes: f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand driver")
Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/atmel/nand-controller.c

index 87481b60f315efef091a6010f13bef77785a7f1d..8c7b086456b5979a26ce149e1459727775a97c0d 100644 (file)
@@ -1853,7 +1853,7 @@ atmel_nand_controller_legacy_add_nands(struct atmel_nand_controller *nc)
 
 static int atmel_nand_controller_add_nands(struct atmel_nand_controller *nc)
 {
-       struct device_node *np, *nand_np;
+       struct device_node *np;
        struct device *dev = nc->dev;
        int ret, reg_cells;
        u32 val;
@@ -1880,7 +1880,7 @@ static int atmel_nand_controller_add_nands(struct atmel_nand_controller *nc)
 
        reg_cells += val;
 
-       for_each_child_of_node(np, nand_np) {
+       for_each_child_of_node_scoped(np, nand_np) {
                struct atmel_nand *nand;
 
                nand = atmel_nand_create(nc, nand_np, reg_cells);