app/testpmd: fix unchecked return value

Message ID 20210316065136.2907-1-kalesh-anakkur.purayil@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series app/testpmd: fix unchecked return value |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/travis-robot success travis build: passed
ci/github-robot success github build: passed
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Functional fail Functional Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

Kalesh A P March 16, 2021, 6:51 a.m. UTC
  From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

This patch checks return value for rte_eth_dev_info_get() in show_macs().

Coverity issue: 353629
Fixes: e1d44d0ad623 ("app/testpmd: show MAC addresses added to a port")
Cc: stable@dpdk.org

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
---
 app/test-pmd/config.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Li, Xiaoyun March 16, 2021, 6:34 a.m. UTC | #1
> -----Original Message-----
> From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
> Sent: Tuesday, March 16, 2021 14:52
> To: dev@dpdk.org
> Cc: Li, Xiaoyun <xiaoyun.li@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
> 
> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> 
> This patch checks return value for rte_eth_dev_info_get() in show_macs().
> 
> Coverity issue: 353629
> Fixes: e1d44d0ad623 ("app/testpmd: show MAC addresses added to a port")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> ---
>  app/test-pmd/config.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> 576d5ac..4ce75a8 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -4930,7 +4930,8 @@ show_macs(portid_t port_id)
> 
>  	dev = &rte_eth_devices[port_id];
> 
> -	rte_eth_dev_info_get(port_id, &dev_info);
> +	if (eth_dev_info_get_print_err(port_id, &dev_info))
> +		return;
> 
>  	for (i = 0; i < dev_info.max_mac_addrs; i++) {
>  		addr = &dev->data->mac_addrs[i];
> --
> 2.10.1

Acked-by: Xiaoyun Li <xiaoyun.li@intel.com>
  
Andrew Rybchenko March 16, 2021, 7:27 a.m. UTC | #2
On 3/16/21 9:34 AM, Li, Xiaoyun wrote:
>> -----Original Message-----
>> From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
>> Sent: Tuesday, March 16, 2021 14:52
>> To: dev@dpdk.org
>> Cc: Li, Xiaoyun <xiaoyun.li@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
>> Subject: [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
>>
>> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>>
>> This patch checks return value for rte_eth_dev_info_get() in show_macs().
>>
>> Coverity issue: 353629
>> Fixes: e1d44d0ad623 ("app/testpmd: show MAC addresses added to a port")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>> ---
>>  app/test-pmd/config.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
>> 576d5ac..4ce75a8 100644
>> --- a/app/test-pmd/config.c
>> +++ b/app/test-pmd/config.c
>> @@ -4930,7 +4930,8 @@ show_macs(portid_t port_id)
>>
>>  	dev = &rte_eth_devices[port_id];
>>
>> -	rte_eth_dev_info_get(port_id, &dev_info);
>> +	if (eth_dev_info_get_print_err(port_id, &dev_info))
>> +		return;
>>
>>  	for (i = 0; i < dev_info.max_mac_addrs; i++) {
>>  		addr = &dev->data->mac_addrs[i];
>> --
>> 2.10.1
> 
> Acked-by: Xiaoyun Li <xiaoyun.li@intel.com>
> 

Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
  
Ferruh Yigit March 16, 2021, 10:18 a.m. UTC | #3
On 3/16/2021 7:27 AM, Andrew Rybchenko wrote:
> On 3/16/21 9:34 AM, Li, Xiaoyun wrote:
>>> -----Original Message-----
>>> From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
>>> Sent: Tuesday, March 16, 2021 14:52
>>> To: dev@dpdk.org
>>> Cc: Li, Xiaoyun <xiaoyun.li@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
>>> Subject: [dpdk-dev] [PATCH] app/testpmd: fix unchecked return value
>>>
>>> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>>>
>>> This patch checks return value for rte_eth_dev_info_get() in show_macs().
>>>
>>> Coverity issue: 353629
>>> Fixes: e1d44d0ad623 ("app/testpmd: show MAC addresses added to a port")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>>> ---
>>>   app/test-pmd/config.c | 3 ++-
>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
>>> 576d5ac..4ce75a8 100644
>>> --- a/app/test-pmd/config.c
>>> +++ b/app/test-pmd/config.c
>>> @@ -4930,7 +4930,8 @@ show_macs(portid_t port_id)
>>>
>>>   	dev = &rte_eth_devices[port_id];
>>>
>>> -	rte_eth_dev_info_get(port_id, &dev_info);
>>> +	if (eth_dev_info_get_print_err(port_id, &dev_info))
>>> +		return;
>>>
>>>   	for (i = 0; i < dev_info.max_mac_addrs; i++) {
>>>   		addr = &dev->data->mac_addrs[i];
>>> --
>>> 2.10.1
>>
>> Acked-by: Xiaoyun Li <xiaoyun.li@intel.com>
>>
> 
> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> 

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

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 576d5ac..4ce75a8 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -4930,7 +4930,8 @@  show_macs(portid_t port_id)
 
 	dev = &rte_eth_devices[port_id];
 
-	rte_eth_dev_info_get(port_id, &dev_info);
+	if (eth_dev_info_get_print_err(port_id, &dev_info))
+		return;
 
 	for (i = 0; i < dev_info.max_mac_addrs; i++) {
 		addr = &dev->data->mac_addrs[i];