diff mbox series

RDMA/rdmavt: fix error code in rvt_create_qp()

Message ID 20211013080645.GD6010@kili (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series RDMA/rdmavt: fix error code in rvt_create_qp() | expand

Commit Message

Dan Carpenter Oct. 13, 2021, 8:06 a.m. UTC
Return negative -ENOMEM instead of positive ENOMEM.  Returning a postive
value will cause an Oops because it becomes an ERR_PTR() in the
create_qp() function.

Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/infiniband/sw/rdmavt/qp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dennis Dalessandro Oct. 13, 2021, 2:16 p.m. UTC | #1
On 10/13/21 4:06 AM, Dan Carpenter wrote:
> Return negative -ENOMEM instead of positive ENOMEM.  Returning a postive
> value will cause an Oops because it becomes an ERR_PTR() in the
> create_qp() function.
> 
> Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/infiniband/sw/rdmavt/qp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
> index 49bdd78ac664..3305f2744bfa 100644
> --- a/drivers/infiniband/sw/rdmavt/qp.c
> +++ b/drivers/infiniband/sw/rdmavt/qp.c
> @@ -1223,7 +1223,7 @@ int rvt_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr,
>  	spin_lock(&rdi->n_qps_lock);
>  	if (rdi->n_qps_allocated == rdi->dparms.props.max_qp) {
>  		spin_unlock(&rdi->n_qps_lock);
> -		ret = ENOMEM;
> +		ret = -ENOMEM;
>  		goto bail_ip;
>  	}
>  
> 

Thanks Dan.

Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Jason Gunthorpe Oct. 13, 2021, 6:19 p.m. UTC | #2
On Wed, Oct 13, 2021 at 11:06:45AM +0300, Dan Carpenter wrote:
> Return negative -ENOMEM instead of positive ENOMEM.  Returning a postive
> value will cause an Oops because it becomes an ERR_PTR() in the
> create_qp() function.
> 
> Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
> ---
>  drivers/infiniband/sw/rdmavt/qp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to for-rc, thanks

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
index 49bdd78ac664..3305f2744bfa 100644
--- a/drivers/infiniband/sw/rdmavt/qp.c
+++ b/drivers/infiniband/sw/rdmavt/qp.c
@@ -1223,7 +1223,7 @@  int rvt_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr,
 	spin_lock(&rdi->n_qps_lock);
 	if (rdi->n_qps_allocated == rdi->dparms.props.max_qp) {
 		spin_unlock(&rdi->n_qps_lock);
-		ret = ENOMEM;
+		ret = -ENOMEM;
 		goto bail_ip;
 	}