[PATCH] mtd: rawnand: r852: disable the engine when card registration fails
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Sun Nov 8 16:24:46 PST 2026
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] mtd: rawnand: r852: ignored sm_controller_ops in
sm_register_device() [1]
--
commit b0db256c0e7e95a57788ef377b493f1dae9d2218
Author: James Hilliard <james.hilliard1 at gmail.com>
mtd: rawnand: r852: disable the engine when card registration fails
This commit calls r852_engine_disable() in the error path of
r852_register_nand_device() when sm_register_device() or
device_create_file() fails.
Link: https://lore.kernel.org/r/sashiko-outbox-204169@kernel.org/
> diff --git a/drivers/mtd/nand/raw/r852.c b/drivers/mtd/nand/raw/r852.c
> index 92c47d351c278..073f96f73be36 100644
> --- a/drivers/mtd/nand/raw/r852.c
> +++ b/drivers/mtd/nand/raw/r852.c
> @@ -656,6 +656,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 */
> dev->card_detected = 0;
> return -1;
[Severity: High]
This problem wasn't introduced by this patch, but does sm_register_device()
called earlier in r852_register_nand_device() have its sm_controller_ops
ignored [1]?
r852_probe() initializes chip->controller to &dev->controller (with
r852_ops), while sm_register_device() sets sm_controller_ops on
chip->legacy.dummy_controller:
drivers/mtd/nand/raw/sm_common.c:sm_register_device() {
...
chip->legacy.dummy_controller.ops = &sm_controller_ops;
flash_ids = smartmedia ? nand_smartmedia_flash_ids : nand_xd_flash_ids;
ret = nand_scan_with_ids(chip, 1, flash_ids);
...
}
Because chip->controller is already non-NULL, nand_set_defaults() ignores
dummy_controller, so nand_attach() calls r852_attach_chip() without calling
sm_attach_chip(), leaving the card's OOB layout, bad-block marker
parameters, and page-size validation unconfigured.
[1] https://sashiko.dev/#/bug/linux-4d4f9cfa-07ac-4319-9927-3acf4cf70ca3
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261108-submit-r852-registration-unwind-v1-v1-1-e54be2c652c2@gmail.com?part=1
More information about the linux-mtd
mailing list