public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: atmel: Fix error handling path in atmel_nand_controller_add_nands
@ 2025-09-22 11:07 Erick Karanja
  2025-09-29 15:55 ` Miquel Raynal
  0 siblings, 1 reply; 3+ messages in thread
From: Erick Karanja @ 2025-09-22 11:07 UTC (permalink / raw)
  To: miquel.raynal
  Cc: richard, vigneshr, nicolas.ferre, alexandre.belloni,
	claudiu.beznea, linux-mtd, linux-arm-kernel, linux-kernel,
	linux-kernel-mentees, Erick Karanja

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>
---
 drivers/mtd/nand/raw/atmel/nand-controller.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c
index db94d14a3807..49e00458eebe 100644
--- a/drivers/mtd/nand/raw/atmel/nand-controller.c
+++ b/drivers/mtd/nand/raw/atmel/nand-controller.c
@@ -1858,7 +1858,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;
@@ -1885,7 +1885,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);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH] mtd: rawnand: atmel: Fix error handling path in atmel_nand_controller_add_nands
@ 2025-09-21 19:09 Erick Karanja
  0 siblings, 0 replies; 3+ messages in thread
From: Erick Karanja @ 2025-09-21 19:09 UTC (permalink / raw)
  To: skhan, david.hunter.linux; +Cc: linux-kernel-mentees, Erick Karanja

If atmel_nand_create() fails, then reference to "nand_np" still 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>
---
 drivers/mtd/nand/raw/atmel/nand-controller.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c
index db94d14a3807..a73c44d79e1b 100644
--- a/drivers/mtd/nand/raw/atmel/nand-controller.c
+++ b/drivers/mtd/nand/raw/atmel/nand-controller.c
@@ -1885,7 +1885,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);
-- 
2.43.0


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

end of thread, other threads:[~2025-09-29 15:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-22 11:07 [PATCH] mtd: rawnand: atmel: Fix error handling path in atmel_nand_controller_add_nands Erick Karanja
2025-09-29 15:55 ` Miquel Raynal
  -- strict thread matches above, loose matches on Subject: below --
2025-09-21 19:09 Erick Karanja

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox