[dpdk-dev,2/3] net/ixgbe: initialise nb_representor_ports value

Message ID 20180430153258.1101-2-declan.doherty@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Helin Zhang
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Doherty, Declan April 30, 2018, 3:32 p.m. UTC
  Initialise rte_ethdev_args nb_representor_ports to zero to handle
the case where no devargs are passed to the IXGBE PF on
device probe, so that there is no invalid attempts to create
representor ports.

Coverity Issue: 277231
Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")

Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Ananyev, Konstantin May 1, 2018, 9:46 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Declan Doherty
> Sent: Monday, April 30, 2018 4:33 PM
> To: dev@dpdk.org
> Cc: Doherty, Declan <declan.doherty@intel.com>
> Subject: [dpdk-dev] [PATCH 2/3] net/ixgbe: initialise nb_representor_ports value
> 
> Initialise rte_ethdev_args nb_representor_ports to zero to handle
> the case where no devargs are passed to the IXGBE PF on
> device probe, so that there is no invalid attempts to create
> representor ports.
> 
> Coverity Issue: 277231
> Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")
> 
> Signed-off-by: Declan Doherty <declan.doherty@intel.com>
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index 0ccf55dc8..283dd7e49 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -1725,8 +1725,7 @@ eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
>  		struct rte_pci_device *pci_dev)
>  {
>  	char name[RTE_ETH_NAME_MAX_LEN];
> -
> -	struct rte_eth_devargs eth_da;
> +	struct rte_eth_devargs eth_da = { .nb_representor_ports = 0 };
>  	int i, retval;
> 
>  	if (pci_dev->device.devargs) {

Might be a bit better:
If (pci_dev->device.devargs) { rte_eth_devargs_parse(...);...}
else memset(&eth_da, 0, sizeof(eth_da));
to be more consistent.
BTW, I think rte_eth_devargs_parse() need to add formal check for input parameters.
Konstantin 



> --
> 2.14.3
  
Doherty, Declan May 1, 2018, 12:53 p.m. UTC | #2
On 01/05/2018 10:46 AM, Ananyev, Konstantin wrote:
> 
> 
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Declan Doherty
>> Sent: Monday, April 30, 2018 4:33 PM
>> To: dev@dpdk.org
>> Cc: Doherty, Declan <declan.doherty@intel.com>
>> Subject: [dpdk-dev] [PATCH 2/3] net/ixgbe: initialise nb_representor_ports value
>>
>> Initialise rte_ethdev_args nb_representor_ports to zero to handle
>> the case where no devargs are passed to the IXGBE PF on
>> device probe, so that there is no invalid attempts to create
>> representor ports.
>>
>> Coverity Issue: 277231
>> Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")
>>
>> Signed-off-by: Declan Doherty <declan.doherty@intel.com>
>> ---
>>   drivers/net/ixgbe/ixgbe_ethdev.c | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
>> index 0ccf55dc8..283dd7e49 100644
>> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
>> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
>> @@ -1725,8 +1725,7 @@ eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
>>   		struct rte_pci_device *pci_dev)
>>   {
>>   	char name[RTE_ETH_NAME_MAX_LEN];
>> -
>> -	struct rte_eth_devargs eth_da;
>> +	struct rte_eth_devargs eth_da = { .nb_representor_ports = 0 };
>>   	int i, retval;
>>
>>   	if (pci_dev->device.devargs) {
> 
> Might be a bit better:
> If (pci_dev->device.devargs) { rte_eth_devargs_parse(...);...}
> else memset(&eth_da, 0, sizeof(eth_da));
> to be more consistent.
> BTW, I think rte_eth_devargs_parse() need to add formal check for input parameters.
> Konstantin
> 

Ok, thanks Konstantin, that makes sense, we're working on cleaning up 
rte_eth_devargs_parse() to align with kvargs so I'll make sure to add 
those checks.

> 
> 
>> --
>> 2.14.3
>
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 0ccf55dc8..283dd7e49 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1725,8 +1725,7 @@  eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 		struct rte_pci_device *pci_dev)
 {
 	char name[RTE_ETH_NAME_MAX_LEN];
-
-	struct rte_eth_devargs eth_da;
+	struct rte_eth_devargs eth_da = { .nb_representor_ports = 0 };
 	int i, retval;
 
 	if (pci_dev->device.devargs) {