[PATCH v2] mtd: rawnand: r852: disable the engine when card registration fails
From: James Hilliard
Date: Fri Dec 04 2026 - 17:27:14 EST
r852_register_nand_device() enables the NAND engine before scanning and
registering the card. If sm_register_device() or device_create_file()
fails, the error path leaves the engine enabled while card_registered
remains clear.
A subsequent removal work item sees no registered card and skips
unregistration. The device removal path also returns immediately from
r852_unregister_nand_device() in this state, so neither path disables
the engine.
Disable the engine in the common registration-failure path after any
required NAND cleanup.
Fixes: 67e054e91924 ("mtd: nand: Add driver for Ricoh xD/SmartMedia reader")
Cc: stable@xxxxxxxxxxxxxxx
Link: https://lore.kernel.org/r/sashiko-outbox-204169@xxxxxxxxxx/
Signed-off-by: James Hilliard <james.hilliard1@xxxxxxxxx>
---
Changes in v2:
- Rebase the registration error path on the accepted card-detection fix.
- Link to v1: https://patch.msgid.link/20261108-submit-r852-registration-unwind-v1-v1-1-e54be2c652c2@xxxxxxxxx
---
drivers/mtd/nand/raw/r852.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/nand/raw/r852.c b/drivers/mtd/nand/raw/r852.c
index 4d95795e1c3a..84d9c60d7909 100644
--- a/drivers/mtd/nand/raw/r852.c
+++ b/drivers/mtd/nand/raw/r852.c
@@ -655,6 +655,7 @@ static int r852_register_nand_device(struct r852_device *dev)
WARN_ON(mtd_device_unregister(nand_to_mtd(dev->chip)));
nand_cleanup(dev->chip);
error1:
+ r852_engine_disable(dev);
/* Force card redetect */
spin_lock_irqsave(&dev->irqlock, flags);
if (!dev->card_unstable)
---
base-commit: dab547f4666f6649360053a95104b8c4480f46a8
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next
change-id: 20261108-submit-r852-registration-unwind-v1-5c7cef4b5a70
Best regards,
--
James Hilliard <james.hilliard1@xxxxxxxxx>