Commit 2c79dad8 authored by Insu Yun's avatar Insu Yun Committed by Doug Ledford

usnic: correctly check failed allocation

Since ib_alloc_device returns allocated memory address, not error,
it should be checked as IS_NULL, not IS_ERR_OR_NULL.
Signed-off-by: default avatarInsu Yun <wuninsu@gmail.com>
Reviewed-by: default avatarDave Goodell <dgoodell@cisco.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent fc81a069
......@@ -343,16 +343,15 @@ static void *usnic_ib_device_add(struct pci_dev *dev)
netdev = pci_get_drvdata(dev);
us_ibdev = (struct usnic_ib_dev *)ib_alloc_device(sizeof(*us_ibdev));
if (IS_ERR_OR_NULL(us_ibdev)) {
if (!us_ibdev) {
usnic_err("Device %s context alloc failed\n",
netdev_name(pci_get_drvdata(dev)));
return ERR_PTR(us_ibdev ? PTR_ERR(us_ibdev) : -EFAULT);
return ERR_PTR(-EFAULT);
}
us_ibdev->ufdev = usnic_fwd_dev_alloc(dev);
if (IS_ERR_OR_NULL(us_ibdev->ufdev)) {
usnic_err("Failed to alloc ufdev for %s with err %ld\n",
pci_name(dev), PTR_ERR(us_ibdev->ufdev));
if (!us_ibdev->ufdev) {
usnic_err("Failed to alloc ufdev for %s\n", pci_name(dev));
goto err_dealloc;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment