From patchwork Thu May 26 13:29:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pattan, Reshma" X-Patchwork-Id: 13027 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 4C464374D; Thu, 26 May 2016 15:29:55 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id B8A9B2C72 for ; Thu, 26 May 2016 15:29:53 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 26 May 2016 06:29:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,367,1459839600"; d="scan'208";a="110930480" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga004.fm.intel.com with ESMTP; 26 May 2016 06:29:51 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u4QDTpOL023297; Thu, 26 May 2016 14:29:51 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u4QDToFC024724; Thu, 26 May 2016 14:29:50 +0100 Received: (from reshmapa@localhost) by sivswdev02.ir.intel.com with id u4QDTorg024720; Thu, 26 May 2016 14:29:50 +0100 From: Reshma Pattan To: dev@dpdk.org Cc: Reshma Pattan Date: Thu, 26 May 2016 14:29:49 +0100 Message-Id: <1464269389-24687-1-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] drivers/net/pcap: fix segfault in pcap pmd X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Testpmd application will crash in fclose() upon quit after running the below command. "sudo gdb --args ./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --vdev 'eth_pcap0,tx_iface=enp1s0f1,rx_pcap=/tmp/test.pcap' -- --port-topology=chained -i" The reason is, pcap vdev creation with tx stream type as "iface" as in above command dont need member ''dumpers'' of "struct tx_pcaps", hence will not have memory allocated. But contains a garbage values, as local object of struct tx_pcaps is not initialized to 0 inside rte_pmd_pcap_dev_init(). So calling pcap_dump_close() on dumper as part of eth_dev_stop() is causing segfault in fclose(). Fix is to initilize local object of struct tx_pcaps to 0. Also initiliaze local object of stcruct rx_pcaps to 0. So during eth_dev_stop(), pcap_dump_close() will not be called if dumper is NULL. Fixes:4c173302("pcap: add new driver") Signed-off-by: Reshma Pattan --- drivers/net/pcap/rte_eth_pcap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index c98e234..e0bb500 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -978,8 +978,8 @@ rte_pmd_pcap_devinit(const char *name, const char *params) unsigned numa_node, using_dumpers = 0; int ret; struct rte_kvargs *kvlist; - struct rx_pcaps pcaps; - struct tx_pcaps dumpers; + struct rx_pcaps pcaps={0}; + struct tx_pcaps dumpers={0}; RTE_LOG(INFO, PMD, "Initializing pmd_pcap for %s\n", name);