public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tokenring: fix module_init error handling
@ 2006-10-28 18:52 Akinobu Mita
  2006-11-01  1:20 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: Akinobu Mita @ 2006-10-28 18:52 UTC (permalink / raw)
  To: linux-kernel, linux-netdev; +Cc: Jeff Garzik, Mike Phillips

- Call platform_driver_unregister() before return when no cards found.
  (fixes data corruption when no cards found)

- Check platform_device_register_simple() return value

Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: Mike Phillips <mikep@linuxtr.net>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

 drivers/net/tokenring/proteon.c |    9 +++++++--
 drivers/net/tokenring/skisa.c   |    9 +++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

Index: work-fault-inject/drivers/net/tokenring/proteon.c
===================================================================
--- work-fault-inject.orig/drivers/net/tokenring/proteon.c
+++ work-fault-inject/drivers/net/tokenring/proteon.c
@@ -370,6 +370,10 @@ static int __init proteon_init(void)
 		dev->dma = dma[i];
 		pdev = platform_device_register_simple("proteon",
 			i, NULL, 0);
+		if (IS_ERR(pdev)) {
+			free_netdev(dev);
+			continue;
+		}
 		err = setup_card(dev, &pdev->dev);
 		if (!err) {
 			proteon_dev[i] = pdev;
@@ -385,9 +389,10 @@ static int __init proteon_init(void)
 	/* Probe for cards. */
 	if (num == 0) {
 		printk(KERN_NOTICE "proteon.c: No cards found.\n");
-		return (-ENODEV);
+		platform_driver_unregister(&proteon_driver);
+		return -ENODEV;
 	}
-	return (0);
+	return 0;
 }
 
 static void __exit proteon_cleanup(void)
Index: work-fault-inject/drivers/net/tokenring/skisa.c
===================================================================
--- work-fault-inject.orig/drivers/net/tokenring/skisa.c
+++ work-fault-inject/drivers/net/tokenring/skisa.c
@@ -380,6 +380,10 @@ static int __init sk_isa_init(void)
 		dev->dma = dma[i];
 		pdev = platform_device_register_simple("skisa",
 			i, NULL, 0);
+		if (IS_ERR(pdev)) {
+			free_netdev(dev);
+			continue;
+		}
 		err = setup_card(dev, &pdev->dev);
 		if (!err) {
 			sk_isa_dev[i] = pdev;
@@ -395,9 +399,10 @@ static int __init sk_isa_init(void)
 	/* Probe for cards. */
 	if (num == 0) {
 		printk(KERN_NOTICE "skisa.c: No cards found.\n");
-		return (-ENODEV);
+		platform_driver_unregister(&sk_isa_driver);
+		return -ENODEV;
 	}
-	return (0);
+	return 0;
 }
 
 static void __exit sk_isa_cleanup(void)

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

* Re: [PATCH] tokenring: fix module_init error handling
  2006-10-28 18:52 [PATCH] tokenring: fix module_init error handling Akinobu Mita
@ 2006-11-01  1:20 ` Jeff Garzik
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2006-11-01  1:20 UTC (permalink / raw)
  To: Akinobu Mita, linux-kernel, linux-netdev, Jeff Garzik,
	Mike Phillips

Akinobu Mita wrote:
> - Call platform_driver_unregister() before return when no cards found.
>   (fixes data corruption when no cards found)
> 
> - Check platform_device_register_simple() return value
> 
> Cc: Jeff Garzik <jgarzik@pobox.com>
> Cc: Mike Phillips <mikep@linuxtr.net>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

applied



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

end of thread, other threads:[~2006-11-01  1:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-28 18:52 [PATCH] tokenring: fix module_init error handling Akinobu Mita
2006-11-01  1:20 ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox