]> git.karo-electronics.de Git - linux-beck.git/commitdiff
RDMA/cxgb4: Initialization errors can cause crash
authorSteve Wise <swise@opengridcomputing.com>
Tue, 10 May 2011 05:06:22 +0000 (22:06 -0700)
committerRoland Dreier <roland@purestorage.com>
Tue, 10 May 2011 05:06:22 +0000 (22:06 -0700)
c4iw_uld_add() must return ERR_PTR() values instead of NULL on failure.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/cxgb4/device.c

index e29172c2afcbe963da9c581f3fdc60798d3fabf4..8e70953c4f474db693a62851be666a1ae763bbdc 100644 (file)
@@ -392,7 +392,7 @@ static struct c4iw_dev *c4iw_alloc(const struct cxgb4_lld_info *infop)
        devp = (struct c4iw_dev *)ib_alloc_device(sizeof(*devp));
        if (!devp) {
                printk(KERN_ERR MOD "Cannot allocate ib device\n");
-               return NULL;
+               return ERR_PTR(-ENOMEM);
        }
        devp->rdev.lldi = *infop;
 
@@ -414,7 +414,7 @@ static struct c4iw_dev *c4iw_alloc(const struct cxgb4_lld_info *infop)
                mutex_unlock(&dev_mutex);
                printk(KERN_ERR MOD "Unable to open CXIO rdev err %d\n", ret);
                ib_dealloc_device(&devp->ibdev);
-               return NULL;
+               return ERR_PTR(ret);
        }
 
        idr_init(&devp->cqidr);
@@ -444,7 +444,7 @@ static void *c4iw_uld_add(const struct cxgb4_lld_info *infop)
                       DRV_VERSION);
 
        dev = c4iw_alloc(infop);
-       if (!dev)
+       if (IS_ERR(dev))
                goto out;
 
        PDBG("%s found device %s nchan %u nrxq %u ntxq %u nports %u\n",