From patchwork Fri Oct 9 16:16:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 80200 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 746D7A04BC; Fri, 9 Oct 2020 18:17:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5B1801BF35; Fri, 9 Oct 2020 18:17:00 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 49C221BCD7; Fri, 9 Oct 2020 18:16:57 +0200 (CEST) IronPort-SDR: BCXOyRajsLsEMlF79VeorkEq1Uw8QIUubp55PDKRGbBycAhz19pRwk2s7arqEeCqkudMAK62oz Qfb/9f2ooizQ== X-IronPort-AV: E=McAfee;i="6000,8403,9769"; a="165618594" X-IronPort-AV: E=Sophos;i="5.77,355,1596524400"; d="scan'208";a="165618594" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2020 09:16:53 -0700 IronPort-SDR: o7s2so1eNrX2BHvwWRHVQWWLOfzy83h7qNMpZJl9YhOjJKMoKwILvc8+YVJrTBKciec/lER1Qp s/bQRNVQsZ2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,355,1596524400"; d="scan'208";a="343886118" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by fmsmga004.fm.intel.com with ESMTP; 09 Oct 2020 09:16:52 -0700 From: Ferruh Yigit To: Ferruh Yigit , Cian Ferriter Cc: dev@dpdk.org, stable@dpdk.org, rchibois@gmail.com Date: Fri, 9 Oct 2020 17:16:49 +0100 Message-Id: <20201009161649.1365261-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] net/pcap: fix possible crash on exit for infinite Rx X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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);