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

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Tue Sep 1 14:59:04 PDT 2015


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=11c7e0e2f91fdfdf9f7b4d107bc93d6c298c95fe
Commit:     11c7e0e2f91fdfdf9f7b4d107bc93d6c298c95fe
Parent:     af83a67cad1452d48ecd77792f9218f26c445650
Author:     Alexey Khoroshilov <khoroshilov at ispras.ru>
AuthorDate: Fri Aug 14 01:37:47 2015 +0300
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Tue Aug 18 17:33:34 2015 -0700

    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: Alexey Khoroshilov <khoroshilov at ispras.ru>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/maps/nettel.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c
index eadcfff..a577ef8 100644
--- a/drivers/mtd/maps/nettel.c
+++ b/drivers/mtd/maps/nettel.c
@@ -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 @@ out_unmap2:
 	iounmap(nettel_mmcrp);
 	iounmap(nettel_amd_map.virt);
 
-	return(rc);
-
+	return rc;
 }
 
 /****************************************************************************/



More information about the linux-mtd-cvs mailing list