patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
To: stable@dpdk.org
Cc: bluca@debian.org, ktraynor@redhat.com
Subject: [dpdk-stable] [PATCH] net/mlx5: fix buffer leakage on Tx queue release
Date: Sat, 17 Apr 2021 18:38:08 +0000	[thread overview]
Message-ID: <20210417183808.5668-1-viacheslavo@nvidia.com> (raw)

On Tx queue release the mlx5 PMD freed the mbufs stored
in the elts array (holds buffers being transmitted) only
for zero reference counter. The one reference is hold
for the queue release call. Hence, on device stop call
the reference counter was at least 2 and elts array was
not freed. If application called the device start without
queue release the elts array was cleaned up and the
remaining mbufs were lost.

Fixes: 6e78005a9b30 ("net/mlx5: add reference counter on DPDK Tx queues")

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

---
This patch is applicable for 19.11LTS only (and possible for
preceeding releases), no bug in 20.11 and Upstream.

 drivers/net/mlx5/mlx5_txq.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 9c929a57ea..d9576e7a64 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -1415,6 +1415,8 @@ mlx5_txq_release(struct rte_eth_dev *dev, uint16_t idx)
 	txq = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl, txq);
 	if (txq->obj && !mlx5_txq_obj_release(txq->obj))
 		txq->obj = NULL;
+	if (rte_atomic32_read(&txq->refcnt <= 2)
+		txq_free_elts(txq);
 	if (rte_atomic32_dec_and_test(&txq->refcnt)) {
 		txq_free_elts(txq);
 		mlx5_mr_btree_free(&txq->txq.mr_ctrl.cache_bh);
-- 
2.28.0


             reply	other threads:[~2021-04-17 18:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-17 18:38 Viacheslav Ovsiienko [this message]
2021-04-19  8:56 ` Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210417183808.5668-1-viacheslavo@nvidia.com \
    --to=viacheslavo@nvidia.com \
    --cc=bluca@debian.org \
    --cc=ktraynor@redhat.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).