linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] infiniband: hw: cxgb4: set errno on failure
@ 2016-12-03 13:04 Pan Bian
  2016-12-03 13:46 ` Steve Wise
  2016-12-14 19:39 ` Doug Ledford
  0 siblings, 2 replies; 3+ messages in thread
From: Pan Bian @ 2016-12-03 13:04 UTC (permalink / raw)
  To: Steve Wise, Doug Ledford, Sean Hefty, Hal Rosenstock, linux-rdma
  Cc: linux-kernel, Pan Bian

From: Pan Bian <bianpan2016@163.com>

In function c4iw_rdev_open(), the value of return variable err should be
negative on errors. However, when the call to __get_free_page() returns
a NULL pointer, its value is not set to "-ENOMEM" and keeps 0. 0 means
no error. And thus, the behavior of its caller may be misled. This patch
fixes the bug.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188821

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/infiniband/hw/cxgb4/device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
index 93e3d27..b99dc9e 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -828,8 +828,10 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
 	}
 	rdev->status_page = (struct t4_dev_status_page *)
 			    __get_free_page(GFP_KERNEL);
-	if (!rdev->status_page)
+	if (!rdev->status_page) {
+		err = -ENOMEM;
 		goto destroy_ocqp_pool;
+	}
 	rdev->status_page->qp_start = rdev->lldi.vr->qp.start;
 	rdev->status_page->qp_size = rdev->lldi.vr->qp.size;
 	rdev->status_page->cq_start = rdev->lldi.vr->cq.start;
-- 
1.9.1

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

* RE: [PATCH 1/1] infiniband: hw: cxgb4: set errno on failure
  2016-12-03 13:04 [PATCH 1/1] infiniband: hw: cxgb4: set errno on failure Pan Bian
@ 2016-12-03 13:46 ` Steve Wise
  2016-12-14 19:39 ` Doug Ledford
  1 sibling, 0 replies; 3+ messages in thread
From: Steve Wise @ 2016-12-03 13:46 UTC (permalink / raw)
  To: 'Pan Bian', 'Steve Wise', 'Doug Ledford',
	'Sean Hefty', 'Hal Rosenstock',
	linux-rdma
  Cc: linux-kernel, 'Pan Bian'

Acked-by: Steve Wise <swise@opengridcomputing.com>

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

* Re: [PATCH 1/1] infiniband: hw: cxgb4: set errno on failure
  2016-12-03 13:04 [PATCH 1/1] infiniband: hw: cxgb4: set errno on failure Pan Bian
  2016-12-03 13:46 ` Steve Wise
@ 2016-12-14 19:39 ` Doug Ledford
  1 sibling, 0 replies; 3+ messages in thread
From: Doug Ledford @ 2016-12-14 19:39 UTC (permalink / raw)
  To: Pan Bian, Steve Wise, Sean Hefty, Hal Rosenstock, linux-rdma
  Cc: linux-kernel, Pan Bian


[-- Attachment #1.1: Type: text/plain, Size: 1452 bytes --]

On 12/3/2016 8:04 AM, Pan Bian wrote:
> From: Pan Bian <bianpan2016@163.com>
> 
> In function c4iw_rdev_open(), the value of return variable err should be
> negative on errors. However, when the call to __get_free_page() returns
> a NULL pointer, its value is not set to "-ENOMEM" and keeps 0. 0 means
> no error. And thus, the behavior of its caller may be misled. This patch
> fixes the bug.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188821
> 
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
>  drivers/infiniband/hw/cxgb4/device.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
> index 93e3d27..b99dc9e 100644
> --- a/drivers/infiniband/hw/cxgb4/device.c
> +++ b/drivers/infiniband/hw/cxgb4/device.c
> @@ -828,8 +828,10 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
>  	}
>  	rdev->status_page = (struct t4_dev_status_page *)
>  			    __get_free_page(GFP_KERNEL);
> -	if (!rdev->status_page)
> +	if (!rdev->status_page) {
> +		err = -ENOMEM;
>  		goto destroy_ocqp_pool;
> +	}
>  	rdev->status_page->qp_start = rdev->lldi.vr->qp.start;
>  	rdev->status_page->qp_size = rdev->lldi.vr->qp.size;
>  	rdev->status_page->cq_start = rdev->lldi.vr->cq.start;
> 

This fix was previously submitted by Wei Yongjun.

-- 
Doug Ledford <dledford@redhat.com>
    GPG Key ID: 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:[~2016-12-14 19:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-03 13:04 [PATCH 1/1] infiniband: hw: cxgb4: set errno on failure Pan Bian
2016-12-03 13:46 ` Steve Wise
2016-12-14 19:39 ` 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).