Skip to content

Commit 95ba385

Browse files
Yue Haibingjgunthorpe
authored andcommitted
RDMA/usnic: Fix passing zero to PTR_ERR in usnic_ib_pci_probe()
drivers/infiniband/hw/usnic/usnic_ib_main.c:590 usnic_ib_pci_probe() warn: passing zero to 'PTR_ERR' Make usnic_ib_device_add() return NULL on fail path, also remove useless NULL check for usnic_ib_discover_pf() Fixes: e3cf00d ("IB/usnic: Add Cisco VIC low-level hardware driver") Link: https://patch.msgid.link/r/20250324123132.2392077-1-yuehaibing@huawei.com Signed-off-by: Yue Haibing <yuehaibing@huawei.com> Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 62dd71e commit 95ba385

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/infiniband/hw/usnic/usnic_ib_main.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static void *usnic_ib_device_add(struct pci_dev *dev)
397397
if (!us_ibdev) {
398398
usnic_err("Device %s context alloc failed\n",
399399
netdev_name(pci_get_drvdata(dev)));
400-
return ERR_PTR(-EFAULT);
400+
return NULL;
401401
}
402402

403403
us_ibdev->ufdev = usnic_fwd_dev_alloc(dev);
@@ -517,8 +517,8 @@ static struct usnic_ib_dev *usnic_ib_discover_pf(struct usnic_vnic *vnic)
517517
}
518518

519519
us_ibdev = usnic_ib_device_add(parent_pci);
520-
if (IS_ERR_OR_NULL(us_ibdev)) {
521-
us_ibdev = us_ibdev ? us_ibdev : ERR_PTR(-EFAULT);
520+
if (!us_ibdev) {
521+
us_ibdev = ERR_PTR(-EFAULT);
522522
goto out;
523523
}
524524

@@ -586,10 +586,10 @@ static int usnic_ib_pci_probe(struct pci_dev *pdev,
586586
}
587587

588588
pf = usnic_ib_discover_pf(vf->vnic);
589-
if (IS_ERR_OR_NULL(pf)) {
590-
usnic_err("Failed to discover pf of vnic %s with err%ld\n",
591-
pci_name(pdev), PTR_ERR(pf));
592-
err = pf ? PTR_ERR(pf) : -EFAULT;
589+
if (IS_ERR(pf)) {
590+
err = PTR_ERR(pf);
591+
usnic_err("Failed to discover pf of vnic %s with err%d\n",
592+
pci_name(pdev), err);
593593
goto out_clean_vnic;
594594
}
595595

0 commit comments

Comments
 (0)