IB/hfi1: Fix potential NULL ptr dereference
authorTadeusz Struk <tadeusz.struk@intel.com>
Thu, 9 Jun 2016 14:51:45 +0000 (07:51 -0700)
committerDoug Ledford <dledford@redhat.com>
Sat, 18 Jun 2016 00:11:27 +0000 (20:11 -0400)
This fixes potential NULL ptr dereference because IS_ERR(dd) doesn't
handle NULL. Fix the issue by initializing the pointer with a not NULL
error code.

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/hfi1/init.c

index 0d28a5a40fae5c2b95daf32168b77e1e097be328..eed971ccd2a1e88e7180f2eae5aba92da5448c96 100644 (file)
@@ -1383,7 +1383,7 @@ static void postinit_cleanup(struct hfi1_devdata *dd)
 static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        int ret = 0, j, pidx, initfail;
-       struct hfi1_devdata *dd = NULL;
+       struct hfi1_devdata *dd = ERR_PTR(-EINVAL);
        struct hfi1_pportdata *ppd;
 
        /* First, lock the non-writable module parameters */