linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: nettel: do not ignore mtd_device_register() failure in nettel_init()
@ 2015-08-13 22:37 Alexey Khoroshilov
  2015-08-19  0:41 ` Brian Norris
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2015-08-13 22:37 UTC (permalink / raw)
  To: David Woodhouse, Brian Norris
  Cc: Alexey Khoroshilov, linux-mtd, linux-kernel, ldv-project

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@ispras.ru>
---
 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 eadcfffc4f9c..a577ef8553d0 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;
 }
 
 /****************************************************************************/
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mtd: nettel: do not ignore mtd_device_register() failure in nettel_init()
  2015-08-13 22:37 [PATCH] mtd: nettel: do not ignore mtd_device_register() failure in nettel_init() Alexey Khoroshilov
@ 2015-08-19  0:41 ` Brian Norris
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Norris @ 2015-08-19  0:41 UTC (permalink / raw)
  To: Alexey Khoroshilov; +Cc: David Woodhouse, linux-mtd, linux-kernel, ldv-project

On Fri, Aug 14, 2015 at 01:37:47AM +0300, Alexey Khoroshilov wrote:
> 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@ispras.ru>

Applied to l2-mtd.git

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-19  0:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-13 22:37 [PATCH] mtd: nettel: do not ignore mtd_device_register() failure in nettel_init() Alexey Khoroshilov
2015-08-19  0:41 ` Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).