* [PATCH] mtd: rawnand: ndfc: clean up the NAND chip if registration fails
@ 2026-11-29 17:13 Cong Nguyen
0 siblings, 0 replies; only message in thread
From: Cong Nguyen @ 2026-11-29 17:13 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
Cc: linux-mtd, linux-kernel
If mtd_device_register() fails in ndfc_chip_init(), the probe fails and
ndfc_remove() never runs, so nothing calls nand_cleanup() for the chip
that nand_scan() set up.
Call nand_cleanup() when mtd_device_register() fails.
Fixes: a808ad3b0d28 ("[MTD] [NAND] ndfc driver")
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
drivers/mtd/nand/raw/ndfc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/mtd/nand/raw/ndfc.c b/drivers/mtd/nand/raw/ndfc.c
index d7b119028a71..9f9d124eb0e5 100644
--- a/drivers/mtd/nand/raw/ndfc.c
+++ b/drivers/mtd/nand/raw/ndfc.c
@@ -174,6 +174,8 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
goto err;
ret = mtd_device_register(mtd, NULL, 0);
+ if (ret)
+ nand_cleanup(chip);
err:
of_node_put(flash_np);
--
2.25.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-29 17:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-29 17:13 [PATCH] mtd: rawnand: ndfc: clean up the NAND chip if registration fails Cong Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®