patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Yuanhan Liu <yliu@fridaylinux.org>
To: Reshma Pattan <reshma.pattan@intel.com>
Cc: David Hunt <david.hunt@intel.com>, dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'test/reorder: fix freeing mbuf twice' has been queued to LTS release 17.11.3
Date: Sun, 20 May 2018 21:02:21 +0800	[thread overview]
Message-ID: <20180520130246.16287-5-yliu@fridaylinux.org> (raw)
In-Reply-To: <20180520130246.16287-1-yliu@fridaylinux.org>

Hi,

FYI, your patch has been queued to LTS release 17.11.3

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

Thanks.

	--yliu

---
>From c123074dd4ce2c417673aff22ccfcc1a6de56501 Mon Sep 17 00:00:00 2001
From: Reshma Pattan <reshma.pattan@intel.com>
Date: Fri, 4 May 2018 11:47:06 +0100
Subject: [PATCH] test/reorder: fix freeing mbuf twice

[ upstream commit ecd867faa860b41a154b3e24f6ea4536562234ab ]

mbufs are being freed twice in error, once in rte_mempool_put_bulk()
and then in rte_reorder_free(). Refactor the code so that we use
rte_reorder_free() to free mbufs in the reorder buffer, and use
rte_pktmbuf_free() to free any unused or drained mbufs.

Fixes: d0c9b58d71 ("app/test: new reorder unit test")

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
Reviewed-by: David Hunt <david.hunt@intel.com>
---
 test/test/test_reorder.c | 47 +++++++++++++++++++++++++++++++++++++----------
 1 file changed, 37 insertions(+), 10 deletions(-)

diff --git a/test/test/test_reorder.c b/test/test/test_reorder.c
index 429f6eb4f..6f2c23069 100644
--- a/test/test/test_reorder.c
+++ b/test/test/test_reorder.c
@@ -175,11 +175,11 @@ test_reorder_insert(void)
 	b = rte_reorder_create("test_insert", rte_socket_id(), size);
 	TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer");
 
-	ret = rte_mempool_get_bulk(p, (void *)bufs, num_bufs);
-	TEST_ASSERT_SUCCESS(ret, "Error getting mbuf from pool");
-
-	for (i = 0; i < num_bufs; i++)
+	for (i = 0; i < num_bufs; i++) {
+		bufs[i] = rte_pktmbuf_alloc(p);
+		TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n");
 		bufs[i]->seqn = i;
+	}
 
 	/* This should fill up order buffer:
 	 * reorder_seq = 0
@@ -194,6 +194,7 @@ test_reorder_insert(void)
 			ret = -1;
 			goto exit;
 		}
+		bufs[i] = NULL;
 	}
 
 	/* early packet - should move mbufs to ready buf and move sequence window
@@ -208,6 +209,7 @@ test_reorder_insert(void)
 		ret = -1;
 		goto exit;
 	}
+	bufs[4] = NULL;
 
 	/* early packet from current sequence window - full ready buffer */
 	bufs[5]->seqn = 2 * size;
@@ -218,6 +220,7 @@ test_reorder_insert(void)
 		ret = -1;
 		goto exit;
 	}
+	bufs[5] = NULL;
 
 	/* late packet */
 	bufs[6]->seqn = 3 * size;
@@ -228,11 +231,15 @@ test_reorder_insert(void)
 		ret = -1;
 		goto exit;
 	}
+	bufs[6] = NULL;
 
 	ret = 0;
 exit:
-	rte_mempool_put_bulk(p, (void *)bufs, num_bufs);
 	rte_reorder_free(b);
+	for (i = 0; i < num_bufs; i++) {
+		if (bufs[i] != NULL)
+			rte_pktmbuf_free(bufs[i]);
+	}
 	return ret;
 }
 
@@ -248,6 +255,10 @@ test_reorder_drain(void)
 	int ret = 0;
 	unsigned i, cnt;
 
+	/* initialize all robufs to NULL */
+	for (i = 0; i < num_bufs; i++)
+		robufs[i] = NULL;
+
 	/* This would create a reorder buffer instance consisting of:
 	 * reorder_seq = 0
 	 * ready_buf: RB[size] = {NULL, NULL, NULL, NULL}
@@ -256,9 +267,6 @@ test_reorder_drain(void)
 	b = rte_reorder_create("test_drain", rte_socket_id(), size);
 	TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer");
 
-	ret = rte_mempool_get_bulk(p, (void *)bufs, num_bufs);
-	TEST_ASSERT_SUCCESS(ret, "Error getting mbuf from pool");
-
 	/* Check no drained packets if reorder is empty */
 	cnt = rte_reorder_drain(b, robufs, 1);
 	if (cnt != 0) {
@@ -268,8 +276,11 @@ test_reorder_drain(void)
 		goto exit;
 	}
 
-	for (i = 0; i < num_bufs; i++)
+	for (i = 0; i < num_bufs; i++) {
+		bufs[i] = rte_pktmbuf_alloc(p);
+		TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n");
 		bufs[i]->seqn = i;
+	}
 
 	/* Insert packet with seqn 1:
 	 * reorder_seq = 0
@@ -277,6 +288,7 @@ test_reorder_drain(void)
 	 * OB[] = {1, NULL, NULL, NULL}
 	 */
 	rte_reorder_insert(b, bufs[1]);
+	bufs[1] = NULL;
 
 	cnt = rte_reorder_drain(b, robufs, 1);
 	if (cnt != 1) {
@@ -285,6 +297,8 @@ test_reorder_drain(void)
 		ret = -1;
 		goto exit;
 	}
+	if (robufs[0] != NULL)
+		rte_pktmbuf_free(robufs[i]);
 
 	/* Insert more packets
 	 * RB[] = {NULL, NULL, NULL, NULL}
@@ -292,18 +306,22 @@ test_reorder_drain(void)
 	 */
 	rte_reorder_insert(b, bufs[2]);
 	rte_reorder_insert(b, bufs[3]);
+	bufs[2] = NULL;
+	bufs[3] = NULL;
 
 	/* Insert more packets
 	 * RB[] = {NULL, NULL, NULL, NULL}
 	 * OB[] = {NULL, 2, 3, 4}
 	 */
 	rte_reorder_insert(b, bufs[4]);
+	bufs[4] = NULL;
 
 	/* Insert more packets
 	 * RB[] = {2, 3, 4, NULL}
 	 * OB[] = {NULL, NULL, 7, NULL}
 	 */
 	rte_reorder_insert(b, bufs[7]);
+	bufs[7] = NULL;
 
 	/* drained expected packets */
 	cnt = rte_reorder_drain(b, robufs, 4);
@@ -313,6 +331,10 @@ test_reorder_drain(void)
 		ret = -1;
 		goto exit;
 	}
+	for (i = 0; i < 3; i++) {
+		if (robufs[i] != NULL)
+			rte_pktmbuf_free(robufs[i]);
+	}
 
 	/*
 	 * RB[] = {NULL, NULL, NULL, NULL}
@@ -327,8 +349,13 @@ test_reorder_drain(void)
 	}
 	ret = 0;
 exit:
-	rte_mempool_put_bulk(p, (void *)bufs, num_bufs);
 	rte_reorder_free(b);
+	for (i = 0; i < num_bufs; i++) {
+		if (bufs[i] != NULL)
+			rte_pktmbuf_free(bufs[i]);
+		if (robufs[i] != NULL)
+			rte_pktmbuf_free(robufs[i]);
+	}
 	return ret;
 }
 
-- 
2.11.0

  parent reply	other threads:[~2018-05-20 13:08 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-20 13:02 [dpdk-stable] patch 'event/dpaa2: remove link from info structure' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'crypto/scheduler: set null pointer after freeing' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'crypto/scheduler: fix memory leak' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/crypto-perf: check minimum lcore number' " Yuanhan Liu
2018-05-20 13:02 ` Yuanhan Liu [this message]
2018-05-20 13:02 ` [dpdk-stable] patch 'test/distributor: fix return type of thread function' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'test/pipeline: fix return type of stub miss' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'examples/quota_watermark: fix return type of threads' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix slave port detection' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix valid ports prints' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix forward ports update' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix forward ports Rx flush' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix synchronic port hotplug' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix removed device link status asking' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'examples/performance-thread: fix return type of threads' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'test/pipeline: fix type of table entry parameter' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'vhost: fix dead lock on closing in server mode' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/vhost: initialise device as inactive' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnxt: fix Rx mbuf and agg ring leak in dev stop' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnxt: fix usage of vnic id' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'app/testpmd: fix empty list of RSS queues for flow' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/failsafe: fix probe cleanup' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/i40e: fix link status update' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bonding: fix slave activation simultaneously' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'mempool: fix virtual address population' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnx2x: do not cast function pointers as a policy' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnx2x: fix KR2 device check' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/bnx2x: fix memzone name overrun' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/i40e: fix failing to disable FDIR Tx queue' " Yuanhan Liu
2018-05-20 13:02 ` [dpdk-stable] patch 'net/ixgbe: fix too many interrupts' " Yuanhan Liu

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=20180520130246.16287-5-yliu@fridaylinux.org \
    --to=yliu@fridaylinux.org \
    --cc=david.hunt@intel.com \
    --cc=reshma.pattan@intel.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).