public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] IB/usnic: clean up some error handling code
@ 2015-06-04  9:02 Dan Carpenter
  2015-06-04 16:14 ` Dave Goodell (dgoodell)
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2015-06-04  9:02 UTC (permalink / raw)
  To: Upinder Malhi
  Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, linux-rdma,
	kernel-janitors

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>

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);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] IB/usnic: clean up some error handling code
  2015-06-04  9:02 [patch] IB/usnic: clean up some error handling code Dan Carpenter
@ 2015-06-04 16:14 ` Dave Goodell (dgoodell)
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Goodell (dgoodell) @ 2015-06-04 16:14 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Upinder Malhi, Doug Ledford, Sean Hefty, Hal Rosenstock,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Jun 4, 2015, at 4:02 AM, Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 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-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

Looks good to me, thanks.

Reviewed-by: Dave Goodell <dgoodell-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>

-Dave

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-04 16:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-04  9:02 [patch] IB/usnic: clean up some error handling code Dan Carpenter
2015-06-04 16:14 ` Dave Goodell (dgoodell)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox