linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usnic: correctly check failed allocation
@ 2015-10-15 21:15 Insu Yun
       [not found] ` <1444943715-31250-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Insu Yun @ 2015-10-15 21:15 UTC (permalink / raw)
  To: umalhi-FYB4Gu1CFyUAvxtiuMwx3w, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: taesoo-/4noJB3qBVQ3uPMLIKxrzw,
	yeongjin.jang-/4noJB3qBVQ3uPMLIKxrzw, insu-/4noJB3qBVQ3uPMLIKxrzw,
	Insu Yun

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: Insu Yun <wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/infiniband/hw/usnic/usnic_ib_main.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/usnic/usnic_ib_main.c b/drivers/infiniband/hw/usnic/usnic_ib_main.c
index 34c49b8..cbc0514 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_main.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_main.c
@@ -328,16 +328,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;
 	}
 
-- 
1.9.1

--
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 related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usnic: correctly check failed allocation
       [not found] ` <1444943715-31250-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-10-15 21:34   ` Dave Goodell
  2015-10-21 20:43   ` Doug Ledford
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Goodell @ 2015-10-15 21:34 UTC (permalink / raw)
  To: Insu Yun
  Cc: umalhi-FYB4Gu1CFyUAvxtiuMwx3w, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	taesoo-/4noJB3qBVQ3uPMLIKxrzw,
	yeongjin.jang-/4noJB3qBVQ3uPMLIKxrzw, insu-/4noJB3qBVQ3uPMLIKxrzw

On Thu, Oct 15, 2015 at 09:15:15PM +0000, Insu Yun wrote:
> 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: Insu Yun <wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Reviewed-by: Dave Goodell <dgoodell-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
--
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] 3+ messages in thread

* Re: [PATCH] usnic: correctly check failed allocation
       [not found] ` <1444943715-31250-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2015-10-15 21:34   ` Dave Goodell
@ 2015-10-21 20:43   ` Doug Ledford
  1 sibling, 0 replies; 3+ messages in thread
From: Doug Ledford @ 2015-10-21 20:43 UTC (permalink / raw)
  To: Insu Yun, umalhi-FYB4Gu1CFyUAvxtiuMwx3w,
	sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
	hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: taesoo-/4noJB3qBVQ3uPMLIKxrzw,
	yeongjin.jang-/4noJB3qBVQ3uPMLIKxrzw, insu-/4noJB3qBVQ3uPMLIKxrzw

[-- Attachment #1: Type: text/plain, Size: 1549 bytes --]

On 10/15/2015 05:15 PM, Insu Yun wrote:
> 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: Insu Yun <wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Thanks, applied.

> ---
>  drivers/infiniband/hw/usnic/usnic_ib_main.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/usnic/usnic_ib_main.c b/drivers/infiniband/hw/usnic/usnic_ib_main.c
> index 34c49b8..cbc0514 100644
> --- a/drivers/infiniband/hw/usnic/usnic_ib_main.c
> +++ b/drivers/infiniband/hw/usnic/usnic_ib_main.c
> @@ -328,16 +328,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;
>  	}
>  
> 


-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
              GPG KeyID: 0E572FDD



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

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

end of thread, other threads:[~2015-10-21 20:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-15 21:15 [PATCH] usnic: correctly check failed allocation Insu Yun
     [not found] ` <1444943715-31250-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-10-15 21:34   ` Dave Goodell
2015-10-21 20:43   ` Doug Ledford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).