From: Mohammad Abdul Awal Date: Tue, 27 Feb 2018 08:58:27 +0000 (+0000) Subject: ethdev: fix string length in name comparison X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b4572daa2c1056ba5a346841135747e8a2ea356e;p=dpdk.git ethdev: fix string length in name comparison 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") Cc: stable@dpdk.org Signed-off-by: Mohammad Abdul Awal Acked-by: Konstantin Ananyev --- diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 0590f0c10e..3b885a62c7 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; }