diff mbox

IB/usnic: clean up some error handling code

Message ID 20150604090218.GD22838@mwanda (mailing list archive)
State Accepted
Headers show

Commit Message

Dan Carpenter June 4, 2015, 9:02 a.m. UTC
This code causes a static checker warning:

	drivers/infiniband/hw/usnic/usnic_uiom.c:476 usnic_uiom_alloc_pd()
	warn: passing zero to 'PTR_ERR'

This code isn't buggy, but iommu_domain_alloc() doesn't return an error
pointer so we can simplify the error handling and silence the static
checker warning.

The static checker warning is to catch place which do:

	if (!ptr)
		return ERR_PTR(ptr);

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Dave Goodell (dgoodell) June 4, 2015, 4:14 p.m. UTC | #1
On Jun 4, 2015, at 4:02 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:

> This code causes a static checker warning:
> 
> 	drivers/infiniband/hw/usnic/usnic_uiom.c:476 usnic_uiom_alloc_pd()
> 	warn: passing zero to 'PTR_ERR'
> 
> This code isn't buggy, but iommu_domain_alloc() doesn't return an error
> pointer so we can simplify the error handling and silence the static
> checker warning.
> 
> The static checker warning is to catch place which do:
> 
> 	if (!ptr)
> 		return ERR_PTR(ptr);
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Looks good to me, thanks.

Reviewed-by: Dave Goodell <dgoodell@cisco.com>

-Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/hw/usnic/usnic_uiom.c
index 417de1f..cb2337f 100644
--- a/drivers/infiniband/hw/usnic/usnic_uiom.c
+++ b/drivers/infiniband/hw/usnic/usnic_uiom.c
@@ -472,11 +472,10 @@  struct usnic_uiom_pd *usnic_uiom_alloc_pd(void)
 		return ERR_PTR(-ENOMEM);
 
 	pd->domain = domain = iommu_domain_alloc(&pci_bus_type);
-	if (IS_ERR_OR_NULL(domain)) {
-		usnic_err("Failed to allocate IOMMU domain with err %ld\n",
-				PTR_ERR(pd->domain));
+	if (!domain) {
+		usnic_err("Failed to allocate IOMMU domain");
 		kfree(pd);
-		return ERR_PTR(domain ? PTR_ERR(domain) : -ENOMEM);
+		return ERR_PTR(-ENOMEM);
 	}
 
 	iommu_set_fault_handler(pd->domain, usnic_uiom_dma_fault, NULL);