From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>,
Cian Ferriter <cian.ferriter@intel.com>
Cc: dev@dpdk.org, stable@dpdk.org, rchibois@gmail.com
Subject: [dpdk-dev] [PATCH] net/pcap: fix possible crash on exit for infinite Rx
Date: Fri, 9 Oct 2020 17:16:49 +0100 [thread overview]
Message-ID: <20201009161649.1365261-1-ferruh.yigit@intel.com> (raw)
If the infinite Rx argument ('infinite_rx') is provided a ring is
allocated and filled in the '.rx_queue_setup' dev_ops.
Later this ring freed in the '.dev_close' dev_ops.
If the 'infinite_rx' provided and '.dev_close' called before
'.rx_queue_setup', the ring will be NULL and trying to empty/free it
will cause a crash.
This is fixed by adding ring NULL check before trying to empty/free it.
Bugzilla ID: 548
Fixes: a3f5252e5cbd ("net/pcap: enable infinitely Rx a pcap file")
Cc: stable@dpdk.org
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: rchibois@gmail.com
Cc: cian.ferriter@intel.com
---
drivers/net/pcap/rte_eth_pcap.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 057aa9dbfc..49764c0ee6 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -748,6 +748,13 @@ eth_dev_close(struct rte_eth_dev *dev)
struct pcap_rx_queue *pcap_q = &internals->rx_queue[i];
struct rte_mbuf *pcap_buf;
+ /*
+ * 'pcap_q->pkts' can be NULL if 'eth_dev_close()'
+ * called before 'eth_rx_queue_setup()' has been called
+ */
+ if (pcap_q->pkts == NULL)
+ continue;
+
while (!rte_ring_dequeue(pcap_q->pkts,
(void **)&pcap_buf))
rte_pktmbuf_free(pcap_buf);
--
2.26.2
next reply other threads:[~2020-10-09 16:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-09 16:16 Ferruh Yigit [this message]
2020-10-12 17:08 ` Ferruh Yigit
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=20201009161649.1365261-1-ferruh.yigit@intel.com \
--to=ferruh.yigit@intel.com \
--cc=cian.ferriter@intel.com \
--cc=dev@dpdk.org \
--cc=rchibois@gmail.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).