mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
mtd: core: fix error path for nvmem provider
commite0489f6e22upstream. If mtd_otp_nvmem_add() fails, the partitions won't be removed because there is simply no call to del_mtd_partitions(). Unfortunately, add_mtd_partitions() will print all partitions to the kernel console. If mtd_otp_nvmem_add() returns -EPROBE_DEFER this would print the partitions multiple times to the kernel console. Instead move mtd_otp_nvmem_add() to the beginning of the function. Fixes:4b361cfa86("mtd: core: add OTP nvmem provider support") Cc: stable@vger.kernel.org Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20230308082021.870459-3-michael@walle.cc Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
26358f3304
commit
f1b4affca1
@@ -1019,10 +1019,14 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
|
|||||||
|
|
||||||
mtd_set_dev_defaults(mtd);
|
mtd_set_dev_defaults(mtd);
|
||||||
|
|
||||||
|
ret = mtd_otp_nvmem_add(mtd);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER)) {
|
if (IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER)) {
|
||||||
ret = add_mtd_device(mtd);
|
ret = add_mtd_device(mtd);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prefer parsed partitions over driver-provided fallback */
|
/* Prefer parsed partitions over driver-provided fallback */
|
||||||
@@ -1057,9 +1061,12 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
|
|||||||
register_reboot_notifier(&mtd->reboot_notifier);
|
register_reboot_notifier(&mtd->reboot_notifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mtd_otp_nvmem_add(mtd);
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
if (ret) {
|
||||||
|
nvmem_unregister(mtd->otp_user_nvmem);
|
||||||
|
nvmem_unregister(mtd->otp_factory_nvmem);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret && device_is_registered(&mtd->dev))
|
if (ret && device_is_registered(&mtd->dev))
|
||||||
del_mtd_device(mtd);
|
del_mtd_device(mtd);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user