@@ -398,13 +398,14 @@ static struct usnic_ib_dev *usnic_ib_discover_pf(struct usnic_vnic *vnic)
us_ibdev = usnic_ib_device_add(parent_pci);
if (IS_ERR_OR_NULL(us_ibdev)) {
- us_ibdev = ERR_PTR(-EINVAL);
+ us_ibdev = (us_ibdev) ? us_ibdev : ERR_PTR(-EFAULT);
goto out;
}
err = usnic_ib_sysfs_register_usdev(us_ibdev);
if (err) {
usnic_ib_device_remove(us_ibdev);
+ us_ibdev = ERR_PTR(err);
goto out;
}
@@ -459,9 +460,10 @@ int usnic_ib_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}
pf = usnic_ib_discover_pf(vf->vnic);
- if (!pf) {
- usnic_err("Failed to discover pf of vnic %s with err%d\n",
- pci_name(pdev), err);
+ if (IS_ERR_OR_NULL(pf)) {
+ usnic_err("Failed to discover pf of vnic %s with err%ld\n",
+ pci_name(pdev), PTR_ERR(pf));
+ err = (pf ? PTR_ERR(pf) : -EFAULT);
goto out_clean_vnic;
}
@@ -574,7 +574,7 @@ struct ib_mr *usnic_ib_reg_mr(struct ib_pd *pd, u64 start, u64 length,
mr->umem = usnic_uiom_reg_get(to_upd(pd)->umem_pd, start, length,
access_flags, 0);
if (IS_ERR_OR_NULL(mr->umem)) {
- err = PTR_ERR(mr->umem);
+ err = (mr->umem) ? PTR_ERR(mr->umem) : -EFAULT;
goto err_free;
}
Errors with IS_ERR_OR_NULL are not handleded correctly in few places in usNIC. This patch remedies that. Signed-off-by: Upinder Malhi <umalhi@cisco.com> --- drivers/infiniband/hw/usnic/usnic_ib_main.c | 10 ++++++---- drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-)