Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: e3cf00d0a87f ("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>

authored by

Yue Haibing and committed by
Jason Gunthorpe
95ba3850 62dd71e6

+7 -7
+7 -7
drivers/infiniband/hw/usnic/usnic_ib_main.c
··· 397 397 if (!us_ibdev) { 398 398 usnic_err("Device %s context alloc failed\n", 399 399 netdev_name(pci_get_drvdata(dev))); 400 - return ERR_PTR(-EFAULT); 400 + return NULL; 401 401 } 402 402 403 403 us_ibdev->ufdev = usnic_fwd_dev_alloc(dev); ··· 517 517 } 518 518 519 519 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); 522 522 goto out; 523 523 } 524 524 ··· 586 586 } 587 587 588 588 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); 593 593 goto out_clean_vnic; 594 594 } 595 595