[dpdk-dev,3/3] net/ixgbe: add null pointer check for pf_ethdev

Message ID 20180430153258.1101-3-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
Add NULL parameter check for rte_eth_dev_allocated() API call to
eth_ixgbe_pci_probe().

Coverity Issue: 277216
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, 3 insertions(+)
  

Comments

Ananyev, Konstantin May 1, 2018, 9:47 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 3/3] net/ixgbe: add null pointer check for pf_ethdev
> 
> Add NULL parameter check for rte_eth_dev_allocated() API call to
> eth_ixgbe_pci_probe().
> 
> Coverity Issue: 277216
> 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, 3 insertions(+)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index 283dd7e49..75f927c06 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -1747,6 +1747,9 @@ eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
>  	struct rte_eth_dev *pf_ethdev = rte_eth_dev_allocated(
>  		pci_dev->device.name);
> 
> +	if (pf_ethdev == NULL)
> +		return -ENODEV;
> +
>  	for (i = 0; i < eth_da.nb_representor_ports; i++) {
>  		struct ixgbe_vf_info *vfinfo;
>  		struct ixgbe_vf_representor representor;
> --

Looks good - can I just ask to move pf_ethdev definition to the top of the function?
To comply with dpdk coding style.
Konstantin

> 2.14.3
  
Doherty, Declan May 1, 2018, 12:53 p.m. UTC | #2
On 01/05/2018 10:47 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 3/3] net/ixgbe: add null pointer check for pf_ethdev
>>
>> Add NULL parameter check for rte_eth_dev_allocated() API call to
>> eth_ixgbe_pci_probe().
>>
>> Coverity Issue: 277216
>> 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, 3 insertions(+)
>>
>> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
>> index 283dd7e49..75f927c06 100644
>> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
>> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
>> @@ -1747,6 +1747,9 @@ eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
>>   	struct rte_eth_dev *pf_ethdev = rte_eth_dev_allocated(
>>   		pci_dev->device.name);
>>
>> +	if (pf_ethdev == NULL)
>> +		return -ENODEV;
>> +
>>   	for (i = 0; i < eth_da.nb_representor_ports; i++) {
>>   		struct ixgbe_vf_info *vfinfo;
>>   		struct ixgbe_vf_representor representor;
>> --
> 
> Looks good - can I just ask to move pf_ethdev definition to the top of the function?
> To comply with dpdk coding style.
> Konstantin
> 
Will do.

>> 2.14.3
>
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 283dd7e49..75f927c06 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1747,6 +1747,9 @@  eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct rte_eth_dev *pf_ethdev = rte_eth_dev_allocated(
 		pci_dev->device.name);
 
+	if (pf_ethdev == NULL)
+		return -ENODEV;
+
 	for (i = 0; i < eth_da.nb_representor_ports; i++) {
 		struct ixgbe_vf_info *vfinfo;
 		struct ixgbe_vf_representor representor;