patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] compress/mlx5: fix QP setup error flow
@ 2021-08-31 20:39 Michael Baum
  2021-09-01  7:47 ` Matan Azrad
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Baum @ 2021-08-31 20:39 UTC (permalink / raw)
  To: dev; +Cc: Matan Azrad, stable

The QP setup function allocates buffer for its opaque MR and register it
into MR structure.

After buffer alloction and before MR registration, it tries allocate MR
Btree.
When the MR Btree allocation fails, the buffer was not freed what caused
a memory leak.

Allocate the MR Btree before buffer alloction.

Fixes: 0165bccdb45f ("compress/mlx5: add memory region management")
Cc: stable@dpdk.org

Signed-off-by: Michael Baum <michaelba@nvidia.com>
---
 drivers/compress/mlx5/mlx5_compress.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/compress/mlx5/mlx5_compress.c b/drivers/compress/mlx5/mlx5_compress.c
index 883e720ec1..c5e0a83a8c 100644
--- a/drivers/compress/mlx5/mlx5_compress.c
+++ b/drivers/compress/mlx5/mlx5_compress.c
@@ -207,6 +207,13 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 		return -rte_errno;
 	}
 	dev->data->queue_pairs[qp_id] = qp;
+	if (mlx5_mr_btree_init(&qp->mr_ctrl.cache_bh, MLX5_MR_BTREE_CACHE_N,
+			       priv->dev_config.socket_id)) {
+		DRV_LOG(ERR, "Cannot allocate MR Btree for qp %u.",
+			(uint32_t)qp_id);
+		rte_errno = ENOMEM;
+		goto err;
+	}
 	opaq_buf = rte_calloc(__func__, (size_t)1 << log_ops_n,
 			      sizeof(struct mlx5_gga_compress_opaque),
 			      sizeof(struct mlx5_gga_compress_opaque));
@@ -215,13 +222,6 @@ mlx5_compress_qp_setup(struct rte_compressdev *dev, uint16_t qp_id,
 		rte_errno = ENOMEM;
 		goto err;
 	}
-	if (mlx5_mr_btree_init(&qp->mr_ctrl.cache_bh, MLX5_MR_BTREE_CACHE_N,
-			       priv->dev_config.socket_id)) {
-		DRV_LOG(ERR, "Cannot allocate MR Btree for qp %u.",
-			(uint32_t)qp_id);
-		rte_errno = ENOMEM;
-		goto err;
-	}
 	qp->entries_n = 1 << log_ops_n;
 	qp->socket_id = socket_id;
 	qp->qp_id = qp_id;
-- 
2.25.1


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

* Re: [dpdk-stable] [PATCH] compress/mlx5: fix QP setup error flow
  2021-08-31 20:39 [dpdk-stable] [PATCH] compress/mlx5: fix QP setup error flow Michael Baum
@ 2021-09-01  7:47 ` Matan Azrad
  2021-09-02 10:14   ` Akhil Goyal
  0 siblings, 1 reply; 3+ messages in thread
From: Matan Azrad @ 2021-09-01  7:47 UTC (permalink / raw)
  To: Michael Baum, dev; +Cc: stable



From: Michael Baum <michaelba@nvidia.com>
> Sent: Tuesday, August 31, 2021 11:40 PM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; stable@dpdk.org
> Subject: [PATCH] compress/mlx5: fix QP setup error flow
> 
> The QP setup function allocates buffer for its opaque MR and register it into
> MR structure.
> 
> After buffer alloction and before MR registration, it tries allocate MR Btree.
> When the MR Btree allocation fails, the buffer was not freed what caused a
> memory leak.
> 
> Allocate the MR Btree before buffer alloction.
> 
> Fixes: 0165bccdb45f ("compress/mlx5: add memory region management")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>

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

* Re: [dpdk-stable] [PATCH] compress/mlx5: fix QP setup error flow
  2021-09-01  7:47 ` Matan Azrad
@ 2021-09-02 10:14   ` Akhil Goyal
  0 siblings, 0 replies; 3+ messages in thread
From: Akhil Goyal @ 2021-09-02 10:14 UTC (permalink / raw)
  To: Matan Azrad, Michael Baum, dev; +Cc: stable

> > The QP setup function allocates buffer for its opaque MR and register it
> into
> > MR structure.
> >
> > After buffer alloction and before MR registration, it tries allocate MR Btree.
> > When the MR Btree allocation fails, the buffer was not freed what caused a
> > memory leak.
> >
> > Allocate the MR Btree before buffer alloction.
> >
> > Fixes: 0165bccdb45f ("compress/mlx5: add memory region management")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Michael Baum <michaelba@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>

Applied to dpdk-next-crypto

Thanks,

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

end of thread, other threads:[~2021-09-02 10:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31 20:39 [dpdk-stable] [PATCH] compress/mlx5: fix QP setup error flow Michael Baum
2021-09-01  7:47 ` Matan Azrad
2021-09-02 10:14   ` Akhil Goyal

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