RDMA/usnic: Fix passing zero to PTR_ERR in usnic_ib_pci_probe()
[ Upstream commit 95ba3850fed03e01b422ab5d7943aeba130c9723 ]
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: e3cf00d0a8
("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4f7b6029ae
commit
344baf8c1f
@@ -380,7 +380,7 @@ static void *usnic_ib_device_add(struct pci_dev *dev)
|
|||||||
if (!us_ibdev) {
|
if (!us_ibdev) {
|
||||||
usnic_err("Device %s context alloc failed\n",
|
usnic_err("Device %s context alloc failed\n",
|
||||||
netdev_name(pci_get_drvdata(dev)));
|
netdev_name(pci_get_drvdata(dev)));
|
||||||
return ERR_PTR(-EFAULT);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
us_ibdev->ufdev = usnic_fwd_dev_alloc(dev);
|
us_ibdev->ufdev = usnic_fwd_dev_alloc(dev);
|
||||||
@@ -500,8 +500,8 @@ static struct usnic_ib_dev *usnic_ib_discover_pf(struct usnic_vnic *vnic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
us_ibdev = usnic_ib_device_add(parent_pci);
|
us_ibdev = usnic_ib_device_add(parent_pci);
|
||||||
if (IS_ERR_OR_NULL(us_ibdev)) {
|
if (!us_ibdev) {
|
||||||
us_ibdev = us_ibdev ? us_ibdev : ERR_PTR(-EFAULT);
|
us_ibdev = ERR_PTR(-EFAULT);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,10 +569,10 @@ static int usnic_ib_pci_probe(struct pci_dev *pdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
pf = usnic_ib_discover_pf(vf->vnic);
|
pf = usnic_ib_discover_pf(vf->vnic);
|
||||||
if (IS_ERR_OR_NULL(pf)) {
|
if (IS_ERR(pf)) {
|
||||||
usnic_err("Failed to discover pf of vnic %s with err%ld\n",
|
err = PTR_ERR(pf);
|
||||||
pci_name(pdev), PTR_ERR(pf));
|
usnic_err("Failed to discover pf of vnic %s with err%d\n",
|
||||||
err = pf ? PTR_ERR(pf) : -EFAULT;
|
pci_name(pdev), err);
|
||||||
goto out_clean_vnic;
|
goto out_clean_vnic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user