From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 84B8023C for ; Fri, 20 Jul 2018 12:49:51 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jul 2018 03:49:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,378,1526367600"; d="scan'208";a="217607613" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by orsmga004.jf.intel.com with ESMTP; 20 Jul 2018 03:49:48 -0700 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.208]) by IRSMSX102.ger.corp.intel.com ([169.254.2.110]) with mapi id 14.03.0319.002; Fri, 20 Jul 2018 11:49:47 +0100 From: "Singh, Jasvinder" To: "Van Haaren, Harry" , "dev@dpdk.org" CC: "Dumitrescu, Cristian" Thread-Topic: [dpdk-dev] [PATCH] net/softnic: fix memory illegal access Thread-Index: AQHUIA5UMhxCwzOofU27ygoSpsZGVqSX2NUAgAAUYuA= Date: Fri, 20 Jul 2018 10:49:46 +0000 Message-ID: <54CBAA185211B4429112C315DA58FF6D335DAEC4@IRSMSX103.ger.corp.intel.com> References: <20180720094439.100562-1-jasvinder.singh@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDM2ODFlYzYtMGIyMi00YTI1LWJjY2QtOTFiM2Q5ZGQ5OTQ3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiMmFEZjRGcW5ndzlTREJIUlJjZjVPOVpYTDhqMGhzTEJsTDJNb0RVZWdxakdqanVxeDU0ZTFcL2wzM0V1Mll6dnMifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] net/softnic: fix memory illegal access 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: , X-List-Received-Date: Fri, 20 Jul 2018 10:49:52 -0000 > -----Original Message----- > From: Van Haaren, Harry > Sent: Friday, July 20, 2018 11:32 AM > To: Singh, Jasvinder ; dev@dpdk.org > Cc: Dumitrescu, Cristian > Subject: RE: [dpdk-dev] [PATCH] net/softnic: fix memory illegal access >=20 > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jasvinder Singh > > Sent: Friday, July 20, 2018 10:45 AM > > To: dev@dpdk.org > > Cc: Dumitrescu, Cristian > > Subject: [dpdk-dev] [PATCH] net/softnic: fix memory illegal access > > > > While deleting the elements from the linked list, TAILQ_FOREACH causes > > read from the freed pointer. Fixes the issue by using for loop instead > > of TAILQ_FOREACH. > > > > Coverity issue: 302867 > > Fixes: bef50bcb1c47 ("net/softnic: implement start and stop") > > > > Signed-off-by: Jasvinder Singh > > Acked-by: Cristian Dumitrescu > > --- > > drivers/net/softnic/rte_eth_softnic_swq.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/softnic/rte_eth_softnic_swq.c > > b/drivers/net/softnic/rte_eth_softnic_swq.c > > index 1944fbb..a1f1899 100644 > > --- a/drivers/net/softnic/rte_eth_softnic_swq.c > > +++ b/drivers/net/softnic/rte_eth_softnic_swq.c > > @@ -36,9 +36,11 @@ softnic_swq_free(struct pmd_internals *p) void > > softnic_softnic_swq_free_keep_rxq_txq(struct pmd_internals *p) { > > - struct softnic_swq *swq; > > + struct softnic_swq *swq, *swq_next; > > + > > + for (swq =3D TAILQ_FIRST(&p->swq_list); swq !=3D NULL; swq =3D swq_ne= xt) { > > + swq_next =3D TAILQ_NEXT(swq, node); > > > > - TAILQ_FOREACH(swq, &p->swq_list, node) { > > if ((strncmp(swq->name, "RXQ", strlen("RXQ")) =3D=3D 0) || > > (strncmp(swq->name, "TXQ", strlen("TXQ")) =3D=3D 0)) > > continue; >=20 >=20 > The TAILQ_FOREACH_SAFE() macro handles exactly this case. Although it is = not > in the linux TAILQ header, DPDK provides it in rte_tailq.h: >=20 > http://git.dpdk.org/dpdk/tree/lib/librte_eal/common/include/rte_tailq.h#n= 13 > 0 >=20 > I think it is cleaner to use the MACRO instead of manually doing the loop= , > linked-list iter + delete is error prone enough already :) Macro lessens the confusion as well :) thanks, Harry!