浏览代码

IB/hfi1: Fix potential NULL ptr dereference

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>
Tadeusz Struk 9 年之前
父节点
当前提交
93dd0a0978
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      drivers/infiniband/hw/hfi1/init.c

+ 1 - 1
drivers/infiniband/hw/hfi1/init.c

@@ -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)
 static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 {
 	int ret = 0, j, pidx, initfail;
 	int ret = 0, j, pidx, initfail;
-	struct hfi1_devdata *dd = NULL;
+	struct hfi1_devdata *dd = ERR_PTR(-EINVAL);
 	struct hfi1_pportdata *ppd;
 	struct hfi1_pportdata *ppd;
 
 
 	/* First, lock the non-writable module parameters */
 	/* First, lock the non-writable module parameters */