diff mbox series

net/ring: fix return value check

Message ID 20190423153100.97996-1-ferruh.yigit@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series net/ring: fix return value check | expand

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Ferruh Yigit April 23, 2019, 3:31 p.m. UTC
'rte_eth_dev_get_port_by_name()' return value is not checked caught by
coverity, adding return value check.

Coverity issue: 305853
Fixes: 96cb19521147 ("net/ring: use EAL APIs in PMD specific API")
Cc: stable@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/ring/rte_eth_ring.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Bruce Richardson April 23, 2019, 3:49 p.m. UTC | #1
On Tue, Apr 23, 2019 at 04:31:00PM +0100, Ferruh Yigit wrote:
> 'rte_eth_dev_get_port_by_name()' return value is not checked caught by
> coverity, adding return value check.
> 
> Coverity issue: 305853
> Fixes: 96cb19521147 ("net/ring: use EAL APIs in PMD specific API")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
>  drivers/net/ring/rte_eth_ring.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
> index 115a882b5..5ec646594 100644
> --- a/drivers/net/ring/rte_eth_ring.c
> +++ b/drivers/net/ring/rte_eth_ring.c
> @@ -385,7 +385,11 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
>  		return -1;
>  	}
>  
> -	rte_eth_dev_get_port_by_name(ring_name, &port_id);
> +	ret = rte_eth_dev_get_port_by_name(ring_name, &port_id);
> +	if (ret) {
> +		rte_errno = ENODEV;
> +		return -1;
> +	}
>  
>  	return port_id;
>  }

Looks reasonable to me.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Ferruh Yigit April 24, 2019, 4:49 p.m. UTC | #2
On 4/23/2019 4:49 PM, Bruce Richardson wrote:
> On Tue, Apr 23, 2019 at 04:31:00PM +0100, Ferruh Yigit wrote:
>> 'rte_eth_dev_get_port_by_name()' return value is not checked caught by
>> coverity, adding return value check.
>>
>> Coverity issue: 305853
>> Fixes: 96cb19521147 ("net/ring: use EAL APIs in PMD specific API")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>> ---
>>  drivers/net/ring/rte_eth_ring.c | 6 +++++-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
>> index 115a882b5..5ec646594 100644
>> --- a/drivers/net/ring/rte_eth_ring.c
>> +++ b/drivers/net/ring/rte_eth_ring.c
>> @@ -385,7 +385,11 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
>>  		return -1;
>>  	}
>>  
>> -	rte_eth_dev_get_port_by_name(ring_name, &port_id);
>> +	ret = rte_eth_dev_get_port_by_name(ring_name, &port_id);
>> +	if (ret) {
>> +		rte_errno = ENODEV;
>> +		return -1;
>> +	}
>>  
>>  	return port_id;
>>  }
> 
> Looks reasonable to me.
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 

Applied to dpdk-next-net/master, thanks.
diff mbox series

Patch

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 115a882b5..5ec646594 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -385,7 +385,11 @@  rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[],
 		return -1;
 	}
 
-	rte_eth_dev_get_port_by_name(ring_name, &port_id);
+	ret = rte_eth_dev_get_port_by_name(ring_name, &port_id);
+	if (ret) {
+		rte_errno = ENODEV;
+		return -1;
+	}
 
 	return port_id;
 }