From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 050793772 for ; Thu, 26 May 2016 19:57:18 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 26 May 2016 10:57:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,369,1459839600"; d="scan'208";a="111088528" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.57]) ([10.237.220.57]) by fmsmga004.fm.intel.com with ESMTP; 26 May 2016 10:57:17 -0700 To: Reshma Pattan , dev@dpdk.org References: <1464269755-26123-1-git-send-email-reshma.pattan@intel.com> From: Ferruh Yigit Message-ID: <574738FC.2080604@intel.com> Date: Thu, 26 May 2016 18:57:16 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <1464269755-26123-1-git-send-email-reshma.pattan@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [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: , X-List-Received-Date: Thu, 26 May 2016 17:57:19 -0000 On 5/26/2016 2:35 PM, Reshma Pattan wrote: > 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" checkpatch complain about long line (> 75 chars) > > 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 s/dont/don't, s/''/" > 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. s/initilize/initialize > Also initiliaze local object of stcruct rx_pcaps to 0. s/initiliaze/initialize, s/stcruct/struct > > 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..c86f17b 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}; I think this is not required to fix mentioned segfault. But I am OK to keep this. > + struct tx_pcaps dumpers = {0}; > > RTE_LOG(INFO, PMD, "Initializing pmd_pcap for %s\n", name); > > please update patch subject tag from "drivers/net/pcap:" to "pcap:" Can you please send a new version with above minor issues fixed? You can keep my ack in new version. Acked-by: Ferruh Yigit