[dpdk-dev,1/2] net/i40e: fix segfault while devarg parsing

Message ID 20180426231647.239502-1-ferruh.yigit@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Ferruh Yigit April 26, 2018, 11:16 p.m. UTC
  device.devargs can be null, don't access device.devargs->args without
null check.

Fixes: e0645348d7c6 ("net/i40e: add support for representor ports")

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: declan.doherty@intel.com
---
 drivers/net/i40e/i40e_ethdev.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
  

Comments

Ferruh Yigit April 26, 2018, 11:24 p.m. UTC | #1
On 4/27/2018 12:16 AM, Ferruh Yigit wrote:
> device.devargs can be null, don't access device.devargs->args without
> null check.
> 
> Fixes: e0645348d7c6 ("net/i40e: add support for representor ports")
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
> Cc: declan.doherty@intel.com

For series,
Squashed into relevant commit in next-net, thanks.
  

Patch

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 6dbea439f..afa9a1c13 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -623,9 +623,12 @@  eth_i40e_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct rte_eth_devargs eth_da = { .nb_representor_ports = 0 };
 	int i, retval;
 
-	retval = rte_eth_devargs_parse(pci_dev->device.devargs->args, &eth_da);
-	if (retval)
-		return retval;
+	if (pci_dev->device.devargs) {
+		retval = rte_eth_devargs_parse(pci_dev->device.devargs->args,
+				&eth_da);
+		if (retval)
+			return retval;
+	}
 
 	/* physical port net_bdf_port */
 	snprintf(name, sizeof(name), "net_%s", pci_dev->device.name);