Commit 11c7e0e2 authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Brian Norris

mtd: nettel: do not ignore mtd_device_register() failure in nettel_init()

If mtd_device_register() fails in nettel_init(), iomap left mapped.

The patch adds failure handling for mtd_device_register().

Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent af83a67c
......@@ -385,20 +385,28 @@ static int __init nettel_init(void)
}
rc = mtd_device_register(intel_mtd, nettel_intel_partitions,
num_intel_partitions);
if (rc)
goto out_map_destroy;
#endif
if (amd_mtd) {
rc = mtd_device_register(amd_mtd, nettel_amd_partitions,
num_amd_partitions);
if (rc)
goto out_mtd_unreg;
}
#ifdef CONFIG_MTD_CFI_INTELEXT
register_reboot_notifier(&nettel_notifier_block);
#endif
return(rc);
return rc;
out_mtd_unreg:
#ifdef CONFIG_MTD_CFI_INTELEXT
mtd_device_unregister(intel_mtd);
out_map_destroy:
map_destroy(intel_mtd);
out_unmap1:
iounmap(nettel_intel_map.virt);
#endif
......@@ -407,8 +415,7 @@ static int __init nettel_init(void)
iounmap(nettel_mmcrp);
iounmap(nettel_amd_map.virt);
return(rc);
return rc;
}
/****************************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment