From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 783534C88 for ; Tue, 27 Feb 2018 10:38:52 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2018 01:38:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,400,1515484800"; d="scan'208";a="34447053" Received: from irsmsx153.ger.corp.intel.com ([163.33.192.75]) by orsmga001.jf.intel.com with ESMTP; 27 Feb 2018 01:38:50 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.221]) by IRSMSX153.ger.corp.intel.com ([169.254.9.213]) with mapi id 14.03.0319.002; Tue, 27 Feb 2018 09:38:49 +0000 From: "Ananyev, Konstantin" To: "Awal, Mohammad Abdul" , "thomas@monjalon.net" CC: "rkerur@gmail.com" , "dev@dpdk.org" Thread-Topic: [PATCH v2] ether: fix invalid string length in ethdev name comparison Thread-Index: AQHTr6k5y7c1E2G3bk21GFqooRa5HqO3/gDg Date: Tue, 27 Feb 2018 09:38:48 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258905783AF@irsmsx105.ger.corp.intel.com> References: <1519721907-25198-1-git-send-email-mohammad.abdul.awal@intel.com> In-Reply-To: <1519721907-25198-1-git-send-email-mohammad.abdul.awal@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNThmODgyYTMtYmJjZC00NDhkLTk0NzYtMWI3MDA3ZDIzYzBjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6Iit0cGZqUXVmT3hCVjM5Z3VXaFk4Nk1PNUE0Tm1HVlBnWkJSdzRpXC9tdnRRPSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] ether: fix invalid string length in ethdev name comparison 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: Tue, 27 Feb 2018 09:38:53 -0000 > -----Original Message----- > From: Awal, Mohammad Abdul > Sent: Tuesday, February 27, 2018 8:58 AM > To: thomas@monjalon.net > Cc: rkerur@gmail.com; dev@dpdk.org; Ananyev, Konstantin ; Awal, Mohammad Abdul > > Subject: [PATCH v2] ether: fix invalid string length in ethdev name compa= rison >=20 > The current code compares two strings upto the length of 1st string > (searched name). If the 1st string is prefix of 2nd string (existing name= ), > the string comparison returns the port_id of earliest prefix matches. > This patch fixes the bug by using strcmp instead of strncmp. >=20 > Fixes: 9c5b8d8b9fe ("ethdev: clean port id retrieval when attaching") >=20 > Signed-off-by: Mohammad Abdul Awal > --- > lib/librte_ether/rte_ethdev.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) >=20 > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.= c > index 0590f0c..3b885a6 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -572,8 +572,7 @@ rte_eth_dev_get_port_by_name(const char *name, uint16= _t *port_id) >=20 > for (pid =3D 0; pid < RTE_MAX_ETHPORTS; pid++) { > if (rte_eth_devices[pid].state !=3D RTE_ETH_DEV_UNUSED && > - !strncmp(name, rte_eth_dev_shared_data->data[pid].name, > - strlen(name))) { > + !strcmp(name, rte_eth_dev_shared_data->data[pid].name)) { > *port_id =3D pid; > return 0; > } > -- Acked-by: Konstantin Ananyev > 2.7.4