patch 'net/nfp: fix memory leak in Rx' has been queued to stable release 20.11.7

luca.boccassi at gmail.com luca.boccassi at gmail.com
Thu Nov 3 10:27:50 CET 2022


Hi,

FYI, your patch has been queued to stable release 20.11.7

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/05/22. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/8975b80d61bcbb4f55f59eb93901f1104cd882e4

Thanks.

Luca Boccassi

---
>From 8975b80d61bcbb4f55f59eb93901f1104cd882e4 Mon Sep 17 00:00:00 2001
From: Long Wu <long.wu at corigine.com>
Date: Thu, 22 Sep 2022 15:09:44 +0200
Subject: [PATCH] net/nfp: fix memory leak in Rx
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[ upstream commit bb340f56fcb7bac9ec04c1c1ca7a2a4f3012c848 ]

nfp_net_recv_pkts() should not return a value that less than 0 and the
inappropriate return value in receive loop also causes the memory leak.
Modify code to avoid return a value less than 0. Furthermore, When
nfp_net_recv_pkts() break out from the receive loop because of packet
problems, a rte_mbuf will not be freed and it will cause memory leak.
Free the rte_mbuf before break out.

Fixes: b812daadad0d ("nfp: add Rx and Tx")

Signed-off-by: Long Wu <long.wu at corigine.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund at corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he at corigine.com>
---
 drivers/net/nfp/nfp_net.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 4fa0bcc9e7..1c2b676676 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -2041,8 +2041,9 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 	struct rte_mbuf *new_mb;
 	uint16_t nb_hold;
 	uint64_t dma_addr;
-	int avail;
+	uint16_t avail;
 
+	avail = 0;
 	rxq = rx_queue;
 	if (unlikely(rxq == NULL)) {
 		/*
@@ -2050,11 +2051,10 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		 * enabled. But the queue needs to be configured
 		 */
 		RTE_LOG_DP(ERR, PMD, "RX Bad queue\n");
-		return -EINVAL;
+		return avail;
 	}
 
 	hw = rxq->hw;
-	avail = 0;
 	nb_hold = 0;
 
 	while (avail < nb_pkts) {
@@ -2120,7 +2120,8 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 				hw->rx_offset,
 				rxq->mbuf_size - hw->rx_offset,
 				mb->data_len);
-			return -EINVAL;
+			rte_pktmbuf_free(mb);
+			break;
 		}
 
 		/* Filling the received mbuf with packet info */
-- 
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-11-03 09:27:31.125868676 +0000
+++ 0092-net-nfp-fix-memory-leak-in-Rx.patch	2022-11-03 09:27:25.557426003 +0000
@@ -1 +1 @@
-From bb340f56fcb7bac9ec04c1c1ca7a2a4f3012c848 Mon Sep 17 00:00:00 2001
+From 8975b80d61bcbb4f55f59eb93901f1104cd882e4 Mon Sep 17 00:00:00 2001
@@ -8,0 +9,2 @@
+[ upstream commit bb340f56fcb7bac9ec04c1c1ca7a2a4f3012c848 ]
+
@@ -17 +18,0 @@
-Cc: stable at dpdk.org
@@ -23 +24 @@
- drivers/net/nfp/nfp_rxtx.c | 9 +++++----
+ drivers/net/nfp/nfp_net.c | 9 +++++----
@@ -26,5 +27,5 @@
-diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
-index c1a1aba539..b8c874d315 100644
---- a/drivers/net/nfp/nfp_rxtx.c
-+++ b/drivers/net/nfp/nfp_rxtx.c
-@@ -247,8 +247,9 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
+diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
+index 4fa0bcc9e7..1c2b676676 100644
+--- a/drivers/net/nfp/nfp_net.c
++++ b/drivers/net/nfp/nfp_net.c
+@@ -2041,8 +2041,9 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
@@ -41 +42 @@
-@@ -256,11 +257,10 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
+@@ -2050,11 +2051,10 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
@@ -54 +55 @@
-@@ -326,7 +326,8 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
+@@ -2120,7 +2120,8 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)


More information about the stable mailing list