]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
RDMA/amso1100: Fix unitialized pseudo_netdev accessed in c2_register_device
authorTom Tucker <tom@opengridcomputing.com>
Wed, 8 Nov 2006 20:23:22 +0000 (14:23 -0600)
committerRoland Dreier <rolandd@cisco.com>
Mon, 13 Nov 2006 17:38:04 +0000 (09:38 -0800)
Rework some load-time error handling: c2_register_device() leaked when
it failed, and the function that called it didn't check the return code.

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/amso1100/c2.c
drivers/infiniband/hw/amso1100/c2_provider.c

index 9e7bd94b958ad528b28b0d06e2bd7f02e4855c76..27fe242ed4353bc33fdb76410c9dcc4fd6cb6b30 100644 (file)
@@ -1155,7 +1155,8 @@ static int __devinit c2_probe(struct pci_dev *pcidev,
                goto bail10;
        }
 
-       c2_register_device(c2dev);
+       if (c2_register_device(c2dev))
+               goto bail10;
 
        return 0;
 
index da98d9f714295062d7e46c5ccd9e03b6e9a93bb2..fef972752912f821a035bca8c03bbb4e18db6b90 100644 (file)
@@ -757,20 +757,17 @@ static struct net_device *c2_pseudo_netdev_init(struct c2_dev *c2dev)
 
 int c2_register_device(struct c2_dev *dev)
 {
-       int ret;
+       int ret = -ENOMEM;
        int i;
 
        /* Register pseudo network device */
        dev->pseudo_netdev = c2_pseudo_netdev_init(dev);
-       if (dev->pseudo_netdev) {
-               ret = register_netdev(dev->pseudo_netdev);
-               if (ret) {
-                       printk(KERN_ERR PFX
-                               "Unable to register netdev, ret = %d\n", ret);
-                       free_netdev(dev->pseudo_netdev);
-                       return ret;
-               }
-       }
+       if (!dev->pseudo_netdev)
+               goto out3;
+
+       ret = register_netdev(dev->pseudo_netdev);
+       if (ret)
+               goto out2;
 
        pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
        strlcpy(dev->ibdev.name, "amso%d", IB_DEVICE_NAME_MAX);
@@ -848,21 +845,25 @@ int c2_register_device(struct c2_dev *dev)
 
        ret = ib_register_device(&dev->ibdev);
        if (ret)
-               return ret;
+               goto out1;
 
        for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) {
                ret = class_device_create_file(&dev->ibdev.class_dev,
                                               c2_class_attributes[i]);
-               if (ret) {
-                       unregister_netdev(dev->pseudo_netdev);
-                       free_netdev(dev->pseudo_netdev);
-                       ib_unregister_device(&dev->ibdev);
-                       return ret;
-               }
+               if (ret)
+                       goto out0;
        }
+       goto out3;
 
-       pr_debug("%s:%u\n", __FUNCTION__, __LINE__);
-       return 0;
+out0:
+       ib_unregister_device(&dev->ibdev);
+out1:
+       unregister_netdev(dev->pseudo_netdev);
+out2:
+       free_netdev(dev->pseudo_netdev);
+out3:
+       pr_debug("%s:%u ret=%d\n", __FUNCTION__, __LINE__, ret);
+       return ret;
 }
 
 void c2_unregister_device(struct c2_dev *dev)