From: Cong Nguyen <congnt264@gmail.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] mtd: rawnand: ndfc: clean up the NAND chip if registration fails
Date: Mon, 30 Nov 2026 00:13:53 +0700 [thread overview]
Message-ID: <20261129171353.476707-1-congnt264@gmail.com> (raw)
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
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: Cong Nguyen <congnt264@gmail.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] mtd: rawnand: ndfc: clean up the NAND chip if registration fails
Date: Mon, 30 Nov 2026 00:13:53 +0700 [thread overview]
Message-ID: <20261129171353.476707-1-congnt264@gmail.com> (raw)
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
next reply other threads:[~2026-11-29 17:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 17:13 Cong Nguyen [this message]
2026-11-29 17:13 ` [PATCH] mtd: rawnand: ndfc: clean up the NAND chip if registration fails Cong Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261129171353.476707-1-congnt264@gmail.com \
--to=congnt264@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.