From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id D49A94C97 for ; Tue, 27 Feb 2018 09:58:40 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2018 00:58:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,400,1515484800"; d="scan'208";a="30043696" Received: from awal-z170x.ir.intel.com ([163.33.210.59]) by FMSMGA003.fm.intel.com with ESMTP; 27 Feb 2018 00:58:36 -0800 From: Mohammad Abdul Awal To: thomas@monjalon.net Cc: rkerur@gmail.com, dev@dpdk.org, konstantin.ananyev@intel.com, Mohammad Abdul Awal Date: Tue, 27 Feb 2018 08:58:27 +0000 Message-Id: <1519721907-25198-1-git-send-email-mohammad.abdul.awal@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [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 08:58:41 -0000 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. Fixes: 9c5b8d8b9fe ("ethdev: clean port id retrieval when attaching") Signed-off-by: Mohammad Abdul Awal --- lib/librte_ether/rte_ethdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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) for (pid = 0; pid < RTE_MAX_ETHPORTS; pid++) { if (rte_eth_devices[pid].state != 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 = pid; return 0; } -- 2.7.4