linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] RDMA/rvt: Fix potential memory leak caused by rvt_alloc_rq
@ 2020-06-14  4:11 Aditya Pakki
  2020-06-16 19:20 ` Dennis Dalessandro
  2020-06-18 12:45 ` Jason Gunthorpe
  0 siblings, 2 replies; 3+ messages in thread
From: Aditya Pakki @ 2020-06-14  4:11 UTC (permalink / raw)
  To: pakki001
  Cc: kjlu, wu000273, Dennis Dalessandro, Mike Marciniszyn,
	Doug Ledford, Jason Gunthorpe, Michael J. Ruhl, linux-rdma,
	linux-kernel

In case of failure of alloc_ud_wq_attr(), the memory allocated by
rvt_alloc_rq() is not freed. Fix it by calling rvt_free_rq() using
the existing clean-up code.

Fixes: d310c4bf8aea ("IB/{rdmavt, hfi1, qib}: Remove AH refcount for UD QPs")
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
v1: Fix incorrect order of  rvt_free_rq and free_ud_wq_attr.
Suggested by Dennis Dalessandro.
---
 drivers/infiniband/sw/rdmavt/qp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
index 511b72809e14..7db35dd6ad74 100644
--- a/drivers/infiniband/sw/rdmavt/qp.c
+++ b/drivers/infiniband/sw/rdmavt/qp.c
@@ -1204,7 +1204,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
 		err = alloc_ud_wq_attr(qp, rdi->dparms.node);
 		if (err) {
 			ret = (ERR_PTR(err));
-			goto bail_driver_priv;
+			goto bail_rq_rvt;
 		}
 
 		if (init_attr->create_flags & IB_QP_CREATE_NETDEV_USE)
@@ -1314,9 +1314,11 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
 	rvt_free_qpn(&rdi->qp_dev->qpn_table, qp->ibqp.qp_num);
 
 bail_rq_wq:
-	rvt_free_rq(&qp->r_rq);
 	free_ud_wq_attr(qp);
 
+bail_rq_rvt:
+	rvt_free_rq(&qp->r_rq);
+
 bail_driver_priv:
 	rdi->driver_f.qp_priv_free(rdi, qp);
 
-- 
2.25.1


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

* Re: [PATCH v2] RDMA/rvt: Fix potential memory leak caused by rvt_alloc_rq
  2020-06-14  4:11 [PATCH v2] RDMA/rvt: Fix potential memory leak caused by rvt_alloc_rq Aditya Pakki
@ 2020-06-16 19:20 ` Dennis Dalessandro
  2020-06-18 12:45 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Dennis Dalessandro @ 2020-06-16 19:20 UTC (permalink / raw)
  To: Aditya Pakki
  Cc: kjlu, wu000273, Mike Marciniszyn, Doug Ledford, Jason Gunthorpe,
	Michael J. Ruhl, linux-rdma, linux-kernel

On 6/14/2020 12:11 AM, Aditya Pakki wrote:
> In case of failure of alloc_ud_wq_attr(), the memory allocated by
> rvt_alloc_rq() is not freed. Fix it by calling rvt_free_rq() using
> the existing clean-up code.
> 
> Fixes: d310c4bf8aea ("IB/{rdmavt, hfi1, qib}: Remove AH refcount for UD QPs")
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
> v1: Fix incorrect order of  rvt_free_rq and free_ud_wq_attr.
> Suggested by Dennis Dalessandro.
> ---
>   drivers/infiniband/sw/rdmavt/qp.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
> index 511b72809e14..7db35dd6ad74 100644
> --- a/drivers/infiniband/sw/rdmavt/qp.c
> +++ b/drivers/infiniband/sw/rdmavt/qp.c
> @@ -1204,7 +1204,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
>   		err = alloc_ud_wq_attr(qp, rdi->dparms.node);
>   		if (err) {
>   			ret = (ERR_PTR(err));
> -			goto bail_driver_priv;
> +			goto bail_rq_rvt;
>   		}
>   
>   		if (init_attr->create_flags & IB_QP_CREATE_NETDEV_USE)
> @@ -1314,9 +1314,11 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
>   	rvt_free_qpn(&rdi->qp_dev->qpn_table, qp->ibqp.qp_num);
>   
>   bail_rq_wq:
> -	rvt_free_rq(&qp->r_rq);
>   	free_ud_wq_attr(qp);
>   
> +bail_rq_rvt:
> +	rvt_free_rq(&qp->r_rq);
> +
>   bail_driver_priv:
>   	rdi->driver_f.qp_priv_free(rdi, qp);
>   
> 

Cool thanks.

Acked-by: Dennis Dalessandro <dennis.dalessandro@intel.com>

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

* Re: [PATCH v2] RDMA/rvt: Fix potential memory leak caused by rvt_alloc_rq
  2020-06-14  4:11 [PATCH v2] RDMA/rvt: Fix potential memory leak caused by rvt_alloc_rq Aditya Pakki
  2020-06-16 19:20 ` Dennis Dalessandro
@ 2020-06-18 12:45 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2020-06-18 12:45 UTC (permalink / raw)
  To: Aditya Pakki
  Cc: kjlu, wu000273, Dennis Dalessandro, Mike Marciniszyn,
	Doug Ledford, Michael J. Ruhl, linux-rdma, linux-kernel

On Sat, Jun 13, 2020 at 11:11:48PM -0500, Aditya Pakki wrote:
> In case of failure of alloc_ud_wq_attr(), the memory allocated by
> rvt_alloc_rq() is not freed. Fix it by calling rvt_free_rq() using
> the existing clean-up code.
> 
> Fixes: d310c4bf8aea ("IB/{rdmavt, hfi1, qib}: Remove AH refcount for UD QPs")
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> Acked-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
> ---
> v1: Fix incorrect order of  rvt_free_rq and free_ud_wq_attr.
> Suggested by Dennis Dalessandro.
> ---
>  drivers/infiniband/sw/rdmavt/qp.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Applied to for-rc, thanks

Jason

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

end of thread, other threads:[~2020-06-18 12:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-14  4:11 [PATCH v2] RDMA/rvt: Fix potential memory leak caused by rvt_alloc_rq Aditya Pakki
2020-06-16 19:20 ` Dennis Dalessandro
2020-06-18 12:45 ` Jason Gunthorpe

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