patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Yuanhan Liu <yuanhan.liu@linux.intel.com>, dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'kni: fix crash caused by freeing mempool' has been queued to LTS release 16.11.2
Date: Mon,  8 May 2017 13:40:13 +0800	[thread overview]
Message-ID: <1494222024-5222-1-git-send-email-yuanhan.liu@linux.intel.com> (raw)

Hi,

FYI, your patch has been queued to LTS release 16.11.2

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/13/17.
So please shout if anyone has objections.

Thanks.

	--yliu

---
>From 02b8ce63972bc7f12a73131941dfb9aacdc57f11 Mon Sep 17 00:00:00 2001
From: Ferruh Yigit <ferruh.yigit@intel.com>
Date: Wed, 3 May 2017 17:10:37 +0100
Subject: [PATCH] kni: fix crash caused by freeing mempool

[ upstream commit 57a484e08a7ef3dea2018157d518b01a891ddfca ]

To clean alloc_q, which has physical addresses of the mbufs, kni lib
free the pkt_mempool, but this leads a crash in kni unit test.

KNI library shouldn't free the pkt_mempool.

Implementation updated to find the mbufs in the alloc_q and return them
back to mempool.

Fixes: 8eba5ebd1811 ("kni: fix possible memory leak")

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_kni/rte_kni.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c
index 52fcd4b..c3f9208 100644
--- a/lib/librte_kni/rte_kni.c
+++ b/lib/librte_kni/rte_kni.c
@@ -451,17 +451,35 @@ kni_free_fifo(struct rte_kni_fifo *fifo)
 	} while (ret);
 }
 
+static void *
+va2pa(struct rte_mbuf *m)
+{
+	return (void *)((unsigned long)m -
+			((unsigned long)m->buf_addr -
+			 (unsigned long)m->buf_physaddr));
+}
+
 static void
-kni_free_fifo_phy(struct rte_mempool *pktmbuf_pool, struct rte_kni_fifo *fifo)
+obj_free(struct rte_mempool *mp __rte_unused, void *opaque, void *obj,
+		unsigned obj_idx __rte_unused)
+{
+	struct rte_mbuf *m = obj;
+	void *mbuf_phys = opaque;
+
+	if (va2pa(m) == mbuf_phys)
+		rte_pktmbuf_free(m);
+}
+
+static void
+kni_free_fifo_phy(struct rte_mempool *mp, struct rte_kni_fifo *fifo)
 {
 	void *mbuf_phys;
 	int ret;
 
-	rte_mempool_free(pktmbuf_pool);
-
-	/* All mbufs alredy freed with rte_mempoll_free, just free the fifo */
 	do {
 		ret = kni_fifo_get(fifo, &mbuf_phys, 1);
+		if (ret)
+			rte_mempool_obj_iter(mp, obj_free, mbuf_phys);
 	} while (ret);
 }
 
@@ -557,14 +575,6 @@ rte_kni_handle_request(struct rte_kni *kni)
 	return 0;
 }
 
-static void *
-va2pa(struct rte_mbuf *m)
-{
-	return (void *)((unsigned long)m -
-			((unsigned long)m->buf_addr -
-			 (unsigned long)m->buf_physaddr));
-}
-
 unsigned
 rte_kni_tx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned num)
 {
-- 
1.9.0

             reply	other threads:[~2017-05-08  5:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-08  5:40 Yuanhan Liu [this message]
2017-05-08  5:40 ` [dpdk-stable] patch 'net: fix stripped VLAN flag for offload emulation' " Yuanhan Liu
2017-05-08  5:40 ` [dpdk-stable] patch 'net/igb: fix VF MAC address setting' " Yuanhan Liu
2017-05-08  5:40 ` Yuanhan Liu
2017-05-08  5:40 ` [dpdk-stable] patch 'net/ixgbe: fix VF Rx mode for allmulticast disabled' " Yuanhan Liu
2017-05-08  5:40 ` [dpdk-stable] patch 'net/ixgbe: fix setting MTU on stopped device' " Yuanhan Liu
2017-05-08  5:40 ` [dpdk-stable] patch 'net/ixgbe: fix memory overflow in 32-bit SSE Rx' " Yuanhan Liu
2017-05-08  5:40 ` [dpdk-stable] patch 'net/i40e: " Yuanhan Liu
2017-05-08  5:40 ` [dpdk-stable] patch 'net/fm10k: " Yuanhan Liu
2017-05-08  5:40 ` [dpdk-stable] patch 'net/vmxnet3: fix build with gcc 7' " Yuanhan Liu
2017-05-08  5:40 ` [dpdk-stable] patch 'doc: explain zlib dependency for bnx2x' " Yuanhan Liu
2017-05-08  5:40 ` [dpdk-stable] patch 'test/cmdline: fix missing break in switch' " 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=1494222024-5222-1-git-send-email-yuanhan.liu@linux.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=ferruh.yigit@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).