DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] ether: fix invalid string length in ethdev name comparison
@ 2018-02-27  8:58 Mohammad Abdul Awal
  2018-02-27  9:38 ` Ananyev, Konstantin
  0 siblings, 1 reply; 3+ messages in thread
From: Mohammad Abdul Awal @ 2018-02-27  8:58 UTC (permalink / raw)
  To: thomas; +Cc: rkerur, dev, konstantin.ananyev, Mohammad Abdul Awal

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 <mohammad.abdul.awal@intel.com>
---
 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH v2] ether: fix invalid string length in ethdev name comparison
  2018-02-27  8:58 [dpdk-dev] [PATCH v2] ether: fix invalid string length in ethdev name comparison Mohammad Abdul Awal
@ 2018-02-27  9:38 ` Ananyev, Konstantin
  2018-03-07 15:25   ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Ananyev, Konstantin @ 2018-02-27  9:38 UTC (permalink / raw)
  To: Awal, Mohammad Abdul, thomas; +Cc: rkerur, dev



> -----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 <konstantin.ananyev@intel.com>; Awal, Mohammad Abdul
> <mohammad.abdul.awal@intel.com>
> Subject: [PATCH v2] ether: fix invalid string length in ethdev 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")
> 
> Signed-off-by: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com>
> ---
>  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;
>  		}
> --

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

> 2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH v2] ether: fix invalid string length in ethdev name comparison
  2018-02-27  9:38 ` Ananyev, Konstantin
@ 2018-03-07 15:25   ` Ferruh Yigit
  0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2018-03-07 15:25 UTC (permalink / raw)
  To: Ananyev, Konstantin, Awal, Mohammad Abdul, thomas; +Cc: rkerur, dev

On 2/27/2018 9:38 AM, Ananyev, Konstantin wrote:
> 
> 
>> -----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 <konstantin.ananyev@intel.com>; Awal, Mohammad Abdul
>> <mohammad.abdul.awal@intel.com>
>> Subject: [PATCH v2] ether: fix invalid string length in ethdev 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")
>>
>> Signed-off-by: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com>

> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

Applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-07 15:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-27  8:58 [dpdk-dev] [PATCH v2] ether: fix invalid string length in ethdev name comparison Mohammad Abdul Awal
2018-02-27  9:38 ` Ananyev, Konstantin
2018-03-07 15:25   ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).