]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] tokenring: fix module_init error handling
authorAkinobu Mita <akinobu.mita@gmail.com>
Sat, 28 Oct 2006 18:52:14 +0000 (03:52 +0900)
committerJeff Garzik <jeff@garzik.org>
Wed, 1 Nov 2006 01:22:05 +0000 (20:22 -0500)
- 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(-)
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/tokenring/proteon.c
drivers/net/tokenring/skisa.c

index 4f756960db2ae94281b4eedd9c1b2eec1c4ec4cc..cb7dbb63c9d9da6b6794dc30045943f4cac4eced 100644 (file)
@@ -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 d6ba41cf3110665ceb3b4a8332921a6baaf28efd..33afea31d87b93b591a640cc3a4771923f7184d2 100644 (file)
@@ -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)