Skip to content

Commit 2a6a445

Browse files
ISCAS-Vulabmiquelraynal
authored andcommitted
mtd: Fix error handling in mtd_device_parse_register() error path
Check and log del_mtd_device() failures. Print an error message with pr_err() to prevent silent failures, but preserve the original error code instead of propagating the secondary error since del_mtd_device() is already in an error handling path. Signed-off-by: Wentao Liang <[email protected]> Signed-off-by: Miquel Raynal <[email protected]>
1 parent 6697dae commit 2a6a445

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/mtd/mtdcore.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
10561056
const struct mtd_partition *parts,
10571057
int nr_parts)
10581058
{
1059-
int ret;
1059+
int ret, err;
10601060

10611061
mtd_set_dev_defaults(mtd);
10621062

@@ -1108,8 +1108,11 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
11081108
nvmem_unregister(mtd->otp_factory_nvmem);
11091109
}
11101110

1111-
if (ret && device_is_registered(&mtd->dev))
1112-
del_mtd_device(mtd);
1111+
if (ret && device_is_registered(&mtd->dev)) {
1112+
err = del_mtd_device(mtd);
1113+
if (err)
1114+
pr_err("Error when deleting MTD device (%d)\n", err);
1115+
}
11131116

11141117
return ret;
11151118
}

0 commit comments

Comments
 (0)