DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] net/ixgbe fix unchecked return value and rte_panic
@ 2020-10-19 12:26 Conor Walsh
  2020-10-19 12:26 ` [dpdk-dev] [PATCH 1/2] net/ixgbe: fix unchecked return value Conor Walsh
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Conor Walsh @ 2020-10-19 12:26 UTC (permalink / raw)
  To: jia.guo, haiyue.wang, ferruh.yigit, mohammad.abdul.awal, declan.doherty
  Cc: dev, Conor Walsh

This patchset resolves a coverity issue where the return value of
rte_eth_switch_domain_alloc() was not being checked and also removes
a use of rte_panic within ixgbe_pf_host_init().

Conor Walsh (2):
  net/ixgbe: fix unchecked return value
  net/ixgbe: remove rte_panic

 drivers/net/ixgbe/ixgbe_ethdev.c |  6 ++++--
 drivers/net/ixgbe/ixgbe_ethdev.h |  2 +-
 drivers/net/ixgbe/ixgbe_pf.c     | 23 ++++++++++++++++++-----
 3 files changed, 23 insertions(+), 8 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 1/2] net/ixgbe: fix unchecked return value
  2020-10-19 12:26 [dpdk-dev] [PATCH 0/2] net/ixgbe fix unchecked return value and rte_panic Conor Walsh
@ 2020-10-19 12:26 ` Conor Walsh
  2020-10-20  8:33   ` Wang, Haiyue
  2020-10-19 12:26 ` [dpdk-dev] [PATCH 2/2] net/ixgbe: remove rte_panic Conor Walsh
  2020-10-20 10:02 ` [dpdk-dev] [PATCH v2 0/2] net/ixgbe fix unchecked return value and rte_panic Conor Walsh
  2 siblings, 1 reply; 12+ messages in thread
From: Conor Walsh @ 2020-10-19 12:26 UTC (permalink / raw)
  To: jia.guo, haiyue.wang, ferruh.yigit, mohammad.abdul.awal, declan.doherty
  Cc: dev, Conor Walsh

The return value of rte_eth_switch_domain_alloc() was not being checked
within ixgbe_pf_host_init() which caused a coverity issue. If the call
fails a warning is logged using PMD_INIT_LOG() and *vfinfo is free'd.
ixgbe_pf_host_init() now has a return value which is checked in
eth_ixgbe_dev_init()

Coverity issue: 362795
Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c |  6 ++++--
 drivers/net/ixgbe/ixgbe_ethdev.h |  2 +-
 drivers/net/ixgbe/ixgbe_pf.c     | 16 +++++++++++++---
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 14a254ab74..49ff523ea8 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1077,7 +1077,7 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
 		IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private);
 	uint32_t ctrl_ext;
 	uint16_t csum;
-	int diag, i;
+	int diag, i, ret;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1256,7 +1256,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
 	memset(hwstrip, 0, sizeof(*hwstrip));
 
 	/* initialize PF if max_vfs not zero */
-	ixgbe_pf_host_init(eth_dev);
+	ret = ixgbe_pf_host_init(eth_dev);
+	if (ret)
+		return ret;
 
 	ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
 	/* let hardware know driver is loaded */
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 9bdef87fbd..89fa472356 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -717,7 +717,7 @@ void ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev);
 
 void ixgbe_vlan_hw_strip_config(struct rte_eth_dev *dev);
 
-void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev);
+int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev);
 
 void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev);
 
diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index ed5f96b1a4..4e25b1e72e 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -66,7 +66,7 @@ ixgbe_mb_intr_setup(struct rte_eth_dev *dev)
 	return 0;
 }
 
-void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
+int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 {
 	struct ixgbe_vf_info **vfinfo =
 		IXGBE_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
@@ -78,19 +78,27 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 		IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	uint16_t vf_num;
 	uint8_t nb_queue;
+	int ret = 0;
 
 	PMD_INIT_FUNC_TRACE();
 
 	RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
 	vf_num = dev_num_vf(eth_dev);
 	if (vf_num == 0)
-		return;
+		return ret;
 
 	*vfinfo = rte_zmalloc("vf_info", sizeof(struct ixgbe_vf_info) * vf_num, 0);
 	if (*vfinfo == NULL)
 		rte_panic("Cannot allocate memory for private VF data\n");
 
-	rte_eth_switch_domain_alloc(&(*vfinfo)->switch_domain_id);
+	ret = rte_eth_switch_domain_alloc(&(*vfinfo)->switch_domain_id);
+	if (ret) {
+		PMD_INIT_LOG(ERR,
+			"failed to allocate switch domain for device %d", ret);
+		rte_free(*vfinfo);
+		*vfinfo = NULL;
+		return ret;
+	}
 
 	memset(mirror_info, 0, sizeof(struct ixgbe_mirror_info));
 	memset(uta_info, 0, sizeof(struct ixgbe_uta_info));
@@ -118,6 +126,8 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 
 	/* set mb interrupt mask */
 	ixgbe_mb_intr_setup(eth_dev);
+
+	return ret;
 }
 
 void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev)
-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH 2/2] net/ixgbe: remove rte_panic
  2020-10-19 12:26 [dpdk-dev] [PATCH 0/2] net/ixgbe fix unchecked return value and rte_panic Conor Walsh
  2020-10-19 12:26 ` [dpdk-dev] [PATCH 1/2] net/ixgbe: fix unchecked return value Conor Walsh
@ 2020-10-19 12:26 ` Conor Walsh
  2020-10-20 10:02 ` [dpdk-dev] [PATCH v2 0/2] net/ixgbe fix unchecked return value and rte_panic Conor Walsh
  2 siblings, 0 replies; 12+ messages in thread
From: Conor Walsh @ 2020-10-19 12:26 UTC (permalink / raw)
  To: jia.guo, haiyue.wang, ferruh.yigit, mohammad.abdul.awal, declan.doherty
  Cc: dev, Conor Walsh

Remove the usage of rte_panic() within ixgbe_pf_host_init()

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
---
 drivers/net/ixgbe/ixgbe_pf.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index 4e25b1e72e..833863af5a 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -88,8 +88,11 @@ int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 		return ret;
 
 	*vfinfo = rte_zmalloc("vf_info", sizeof(struct ixgbe_vf_info) * vf_num, 0);
-	if (*vfinfo == NULL)
-		rte_panic("Cannot allocate memory for private VF data\n");
+	if (*vfinfo == NULL) {
+		PMD_INIT_LOG(ERR,
+			"Cannot allocate memory for private VF data");
+		return -ENOMEM;
+	}
 
 	ret = rte_eth_switch_domain_alloc(&(*vfinfo)->switch_domain_id);
 	if (ret) {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] net/ixgbe: fix unchecked return value
  2020-10-19 12:26 ` [dpdk-dev] [PATCH 1/2] net/ixgbe: fix unchecked return value Conor Walsh
@ 2020-10-20  8:33   ` Wang, Haiyue
  2020-10-20  9:07     ` Walsh, Conor
  0 siblings, 1 reply; 12+ messages in thread
From: Wang, Haiyue @ 2020-10-20  8:33 UTC (permalink / raw)
  To: Walsh, Conor, Guo, Jia, Yigit, Ferruh, Awal, Mohammad Abdul,
	Doherty, Declan
  Cc: dev

> -----Original Message-----
> From: Walsh, Conor <conor.walsh@intel.com>
> Sent: Monday, October 19, 2020 20:26
> To: Guo, Jia <jia.guo@intel.com>; Wang, Haiyue <haiyue.wang@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>; Awal, Mohammad Abdul <mohammad.abdul.awal@intel.com>; Doherty, Declan
> <declan.doherty@intel.com>
> Cc: dev@dpdk.org; Walsh, Conor <conor.walsh@intel.com>
> Subject: [PATCH 1/2] net/ixgbe: fix unchecked return value
> 
> The return value of rte_eth_switch_domain_alloc() was not being checked
> within ixgbe_pf_host_init() which caused a coverity issue. If the call
> fails a warning is logged using PMD_INIT_LOG() and *vfinfo is free'd.
> ixgbe_pf_host_init() now has a return value which is checked in
> eth_ixgbe_dev_init()
> 
> Coverity issue: 362795
> Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")
> 
> Signed-off-by: Conor Walsh <conor.walsh@intel.com>
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c |  6 ++++--
>  drivers/net/ixgbe/ixgbe_ethdev.h |  2 +-
>  drivers/net/ixgbe/ixgbe_pf.c     | 16 +++++++++++++---
>  3 files changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index 14a254ab74..49ff523ea8 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -1077,7 +1077,7 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
>  		IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private);
>  	uint32_t ctrl_ext;
>  	uint16_t csum;
> -	int diag, i;
> +	int diag, i, ret;
> 
>  	PMD_INIT_FUNC_TRACE();
> 
> @@ -1256,7 +1256,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
>  	memset(hwstrip, 0, sizeof(*hwstrip));
> 
>  	/* initialize PF if max_vfs not zero */
> -	ixgbe_pf_host_init(eth_dev);
> +	ret = ixgbe_pf_host_init(eth_dev);
> +	if (ret)
> +		return ret;
> 

Seems that just return is not enough, the eth_dev->data->mac_addrs and eth_dev->data->hash_mac_addrs
also needs to be freed, please refer to ' ice_dev_init':

static int
ice_dev_init(struct rte_eth_dev *dev)

	rte_free(dev->data->mac_addrs);
	dev->data->mac_addrs = NULL;


> --
> 2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] net/ixgbe: fix unchecked return value
  2020-10-20  8:33   ` Wang, Haiyue
@ 2020-10-20  9:07     ` Walsh, Conor
  0 siblings, 0 replies; 12+ messages in thread
From: Walsh, Conor @ 2020-10-20  9:07 UTC (permalink / raw)
  To: Wang, Haiyue, Guo, Jia, Yigit, Ferruh, Awal, Mohammad Abdul,
	Doherty, Declan
  Cc: dev

Thanks Haiyue,

I will implement a v2, following your suggestions.

/Conor.

> -----Original Message-----
> From: Wang, Haiyue <haiyue.wang@intel.com>
> Sent: Tuesday 20 October 2020 09:34
> To: Walsh, Conor <conor.walsh@intel.com>; Guo, Jia <jia.guo@intel.com>;
> Yigit, Ferruh <ferruh.yigit@intel.com>; Awal, Mohammad Abdul
> <mohammad.abdul.awal@intel.com>; Doherty, Declan
> <declan.doherty@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH 1/2] net/ixgbe: fix unchecked return value
> 
> > -----Original Message-----
> > From: Walsh, Conor <conor.walsh@intel.com>
> > Sent: Monday, October 19, 2020 20:26
> > To: Guo, Jia <jia.guo@intel.com>; Wang, Haiyue
> <haiyue.wang@intel.com>; Yigit, Ferruh
> > <ferruh.yigit@intel.com>; Awal, Mohammad Abdul
> <mohammad.abdul.awal@intel.com>; Doherty, Declan
> > <declan.doherty@intel.com>
> > Cc: dev@dpdk.org; Walsh, Conor <conor.walsh@intel.com>
> > Subject: [PATCH 1/2] net/ixgbe: fix unchecked return value
> >
> > The return value of rte_eth_switch_domain_alloc() was not being checked
> > within ixgbe_pf_host_init() which caused a coverity issue. If the call
> > fails a warning is logged using PMD_INIT_LOG() and *vfinfo is free'd.
> > ixgbe_pf_host_init() now has a return value which is checked in
> > eth_ixgbe_dev_init()
> >
> > Coverity issue: 362795
> > Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")
> >
> > Signed-off-by: Conor Walsh <conor.walsh@intel.com>
> > ---
> >  drivers/net/ixgbe/ixgbe_ethdev.c |  6 ++++--
> >  drivers/net/ixgbe/ixgbe_ethdev.h |  2 +-
> >  drivers/net/ixgbe/ixgbe_pf.c     | 16 +++++++++++++---
> >  3 files changed, 18 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
> b/drivers/net/ixgbe/ixgbe_ethdev.c
> > index 14a254ab74..49ff523ea8 100644
> > --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> > @@ -1077,7 +1077,7 @@ eth_ixgbe_dev_init(struct rte_eth_dev
> *eth_dev, void *init_params __rte_unused)
> >  		IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data-
> >dev_private);
> >  	uint32_t ctrl_ext;
> >  	uint16_t csum;
> > -	int diag, i;
> > +	int diag, i, ret;
> >
> >  	PMD_INIT_FUNC_TRACE();
> >
> > @@ -1256,7 +1256,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev
> *eth_dev, void *init_params __rte_unused)
> >  	memset(hwstrip, 0, sizeof(*hwstrip));
> >
> >  	/* initialize PF if max_vfs not zero */
> > -	ixgbe_pf_host_init(eth_dev);
> > +	ret = ixgbe_pf_host_init(eth_dev);
> > +	if (ret)
> > +		return ret;
> >
> 
> Seems that just return is not enough, the eth_dev->data->mac_addrs and
> eth_dev->data->hash_mac_addrs
> also needs to be freed, please refer to ' ice_dev_init':
> 
> static int
> ice_dev_init(struct rte_eth_dev *dev)
> 
> 	rte_free(dev->data->mac_addrs);
> 	dev->data->mac_addrs = NULL;
> 
> 
> > --
> > 2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH v2 0/2] net/ixgbe fix unchecked return value and rte_panic
  2020-10-19 12:26 [dpdk-dev] [PATCH 0/2] net/ixgbe fix unchecked return value and rte_panic Conor Walsh
  2020-10-19 12:26 ` [dpdk-dev] [PATCH 1/2] net/ixgbe: fix unchecked return value Conor Walsh
  2020-10-19 12:26 ` [dpdk-dev] [PATCH 2/2] net/ixgbe: remove rte_panic Conor Walsh
@ 2020-10-20 10:02 ` Conor Walsh
  2020-10-20 10:02   ` [dpdk-dev] [PATCH v2 1/2] net/ixgbe: fix unchecked return value Conor Walsh
  2020-10-20 10:02   ` [dpdk-dev] [PATCH v2 2/2] net/ixgbe: remove rte_panic Conor Walsh
  2 siblings, 2 replies; 12+ messages in thread
From: Conor Walsh @ 2020-10-20 10:02 UTC (permalink / raw)
  To: jia.guo, haiyue.wang, ferruh.yigit, mohammad.abdul.awal,
	declan.doherty, stable
  Cc: dev, Conor Walsh

This patchset resolves a coverity issue where the return value of
rte_eth_switch_domain_alloc() was not being checked and also removes
a use of rte_panic within ixgbe_pf_host_init().

---

v2: eth_dev->data->mac_addrs and eth_dev->data->hash_mac_addrs will now
be free'd if ixgbe_pf_host_init() fails in eth_ixgbe_dev_init()

Conor Walsh (2):
  net/ixgbe: fix unchecked return value
  net/ixgbe: remove rte_panic

 drivers/net/ixgbe/ixgbe_ethdev.c | 11 +++++++++--
 drivers/net/ixgbe/ixgbe_ethdev.h |  2 +-
 drivers/net/ixgbe/ixgbe_pf.c     | 23 ++++++++++++++++++-----
 3 files changed, 28 insertions(+), 8 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH v2 1/2] net/ixgbe: fix unchecked return value
  2020-10-20 10:02 ` [dpdk-dev] [PATCH v2 0/2] net/ixgbe fix unchecked return value and rte_panic Conor Walsh
@ 2020-10-20 10:02   ` Conor Walsh
  2020-10-20 17:05     ` Wang, Haiyue
  2020-10-20 10:02   ` [dpdk-dev] [PATCH v2 2/2] net/ixgbe: remove rte_panic Conor Walsh
  1 sibling, 1 reply; 12+ messages in thread
From: Conor Walsh @ 2020-10-20 10:02 UTC (permalink / raw)
  To: jia.guo, haiyue.wang, ferruh.yigit, mohammad.abdul.awal,
	declan.doherty, stable
  Cc: dev, Conor Walsh

The return value of rte_eth_switch_domain_alloc() was not being checked
within ixgbe_pf_host_init() which caused a coverity issue. If the call
fails a warning is logged using PMD_INIT_LOG() and *vfinfo is free'd.
ixgbe_pf_host_init() now has a return value which is checked in
eth_ixgbe_dev_init()

Coverity issue: 362795
Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 11 +++++++++--
 drivers/net/ixgbe/ixgbe_ethdev.h |  2 +-
 drivers/net/ixgbe/ixgbe_pf.c     | 16 +++++++++++++---
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 14a254ab74..f094c8d150 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1077,7 +1077,7 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
 		IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private);
 	uint32_t ctrl_ext;
 	uint16_t csum;
-	int diag, i;
+	int diag, i, ret;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1256,7 +1256,14 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
 	memset(hwstrip, 0, sizeof(*hwstrip));
 
 	/* initialize PF if max_vfs not zero */
-	ixgbe_pf_host_init(eth_dev);
+	ret = ixgbe_pf_host_init(eth_dev);
+	if (ret) {
+		rte_free(eth_dev->data->mac_addrs);
+		eth_dev->data->mac_addrs = NULL;
+		rte_free(eth_dev->data->hash_mac_addrs);
+		eth_dev->data->hash_mac_addrs = NULL;
+		return ret;
+	}
 
 	ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
 	/* let hardware know driver is loaded */
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 9bdef87fbd..89fa472356 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -717,7 +717,7 @@ void ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev);
 
 void ixgbe_vlan_hw_strip_config(struct rte_eth_dev *dev);
 
-void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev);
+int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev);
 
 void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev);
 
diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index ed5f96b1a4..4e25b1e72e 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -66,7 +66,7 @@ ixgbe_mb_intr_setup(struct rte_eth_dev *dev)
 	return 0;
 }
 
-void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
+int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 {
 	struct ixgbe_vf_info **vfinfo =
 		IXGBE_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);
@@ -78,19 +78,27 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 		IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	uint16_t vf_num;
 	uint8_t nb_queue;
+	int ret = 0;
 
 	PMD_INIT_FUNC_TRACE();
 
 	RTE_ETH_DEV_SRIOV(eth_dev).active = 0;
 	vf_num = dev_num_vf(eth_dev);
 	if (vf_num == 0)
-		return;
+		return ret;
 
 	*vfinfo = rte_zmalloc("vf_info", sizeof(struct ixgbe_vf_info) * vf_num, 0);
 	if (*vfinfo == NULL)
 		rte_panic("Cannot allocate memory for private VF data\n");
 
-	rte_eth_switch_domain_alloc(&(*vfinfo)->switch_domain_id);
+	ret = rte_eth_switch_domain_alloc(&(*vfinfo)->switch_domain_id);
+	if (ret) {
+		PMD_INIT_LOG(ERR,
+			"failed to allocate switch domain for device %d", ret);
+		rte_free(*vfinfo);
+		*vfinfo = NULL;
+		return ret;
+	}
 
 	memset(mirror_info, 0, sizeof(struct ixgbe_mirror_info));
 	memset(uta_info, 0, sizeof(struct ixgbe_uta_info));
@@ -118,6 +126,8 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 
 	/* set mb interrupt mask */
 	ixgbe_mb_intr_setup(eth_dev);
+
+	return ret;
 }
 
 void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev)
-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev] [PATCH v2 2/2] net/ixgbe: remove rte_panic
  2020-10-20 10:02 ` [dpdk-dev] [PATCH v2 0/2] net/ixgbe fix unchecked return value and rte_panic Conor Walsh
  2020-10-20 10:02   ` [dpdk-dev] [PATCH v2 1/2] net/ixgbe: fix unchecked return value Conor Walsh
@ 2020-10-20 10:02   ` Conor Walsh
  2020-10-20 17:06     ` Wang, Haiyue
  1 sibling, 1 reply; 12+ messages in thread
From: Conor Walsh @ 2020-10-20 10:02 UTC (permalink / raw)
  To: jia.guo, haiyue.wang, ferruh.yigit, mohammad.abdul.awal,
	declan.doherty, stable
  Cc: dev, Conor Walsh

Remove the usage of rte_panic() within ixgbe_pf_host_init()

Signed-off-by: Conor Walsh <conor.walsh@intel.com>
---
 drivers/net/ixgbe/ixgbe_pf.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index 4e25b1e72e..833863af5a 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -88,8 +88,11 @@ int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)
 		return ret;
 
 	*vfinfo = rte_zmalloc("vf_info", sizeof(struct ixgbe_vf_info) * vf_num, 0);
-	if (*vfinfo == NULL)
-		rte_panic("Cannot allocate memory for private VF data\n");
+	if (*vfinfo == NULL) {
+		PMD_INIT_LOG(ERR,
+			"Cannot allocate memory for private VF data");
+		return -ENOMEM;
+	}
 
 	ret = rte_eth_switch_domain_alloc(&(*vfinfo)->switch_domain_id);
 	if (ret) {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/2] net/ixgbe: fix unchecked return value
  2020-10-20 10:02   ` [dpdk-dev] [PATCH v2 1/2] net/ixgbe: fix unchecked return value Conor Walsh
@ 2020-10-20 17:05     ` Wang, Haiyue
  2020-10-23  0:59       ` Zhang, Qi Z
  0 siblings, 1 reply; 12+ messages in thread
From: Wang, Haiyue @ 2020-10-20 17:05 UTC (permalink / raw)
  To: Walsh, Conor, Guo, Jia, Yigit, Ferruh, Awal, Mohammad Abdul,
	Doherty, Declan, stable
  Cc: dev

> -----Original Message-----
> From: Walsh, Conor <conor.walsh@intel.com>
> Sent: Tuesday, October 20, 2020 18:03
> To: Guo, Jia <jia.guo@intel.com>; Wang, Haiyue <haiyue.wang@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>; Awal, Mohammad Abdul <mohammad.abdul.awal@intel.com>; Doherty, Declan
> <declan.doherty@intel.com>; stable@dpdk.org
> Cc: dev@dpdk.org; Walsh, Conor <conor.walsh@intel.com>
> Subject: [PATCH v2 1/2] net/ixgbe: fix unchecked return value
> 
> The return value of rte_eth_switch_domain_alloc() was not being checked
> within ixgbe_pf_host_init() which caused a coverity issue. If the call
> fails a warning is logged using PMD_INIT_LOG() and *vfinfo is free'd.
> ixgbe_pf_host_init() now has a return value which is checked in
> eth_ixgbe_dev_init()
> 
> Coverity issue: 362795
> Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")
> 
> Signed-off-by: Conor Walsh <conor.walsh@intel.com>
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 11 +++++++++--
>  drivers/net/ixgbe/ixgbe_ethdev.h |  2 +-
>  drivers/net/ixgbe/ixgbe_pf.c     | 16 +++++++++++++---
>  3 files changed, 23 insertions(+), 6 deletions(-)

Acked-by: Haiyue Wang <haiyue.wang@intel.com>

> --
> 2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/2] net/ixgbe: remove rte_panic
  2020-10-20 10:02   ` [dpdk-dev] [PATCH v2 2/2] net/ixgbe: remove rte_panic Conor Walsh
@ 2020-10-20 17:06     ` Wang, Haiyue
  2020-10-23  0:59       ` Zhang, Qi Z
  0 siblings, 1 reply; 12+ messages in thread
From: Wang, Haiyue @ 2020-10-20 17:06 UTC (permalink / raw)
  To: Walsh, Conor, Guo, Jia, Yigit, Ferruh, Awal, Mohammad Abdul,
	Doherty, Declan, stable
  Cc: dev

> -----Original Message-----
> From: Walsh, Conor <conor.walsh@intel.com>
> Sent: Tuesday, October 20, 2020 18:03
> To: Guo, Jia <jia.guo@intel.com>; Wang, Haiyue <haiyue.wang@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>; Awal, Mohammad Abdul <mohammad.abdul.awal@intel.com>; Doherty, Declan
> <declan.doherty@intel.com>; stable@dpdk.org
> Cc: dev@dpdk.org; Walsh, Conor <conor.walsh@intel.com>
> Subject: [PATCH v2 2/2] net/ixgbe: remove rte_panic
> 
> Remove the usage of rte_panic() within ixgbe_pf_host_init()
> 
> Signed-off-by: Conor Walsh <conor.walsh@intel.com>
> ---
>  drivers/net/ixgbe/ixgbe_pf.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 

Acked-by: Haiyue Wang <haiyue.wang@intel.com>

> --
> 2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/2] net/ixgbe: fix unchecked return value
  2020-10-20 17:05     ` Wang, Haiyue
@ 2020-10-23  0:59       ` Zhang, Qi Z
  0 siblings, 0 replies; 12+ messages in thread
From: Zhang, Qi Z @ 2020-10-23  0:59 UTC (permalink / raw)
  To: Wang, Haiyue, Walsh, Conor, Guo, Jia, Yigit, Ferruh, Awal,
	Mohammad Abdul, Doherty, Declan, stable
  Cc: dev



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Wang, Haiyue
> Sent: Wednesday, October 21, 2020 1:06 AM
> To: Walsh, Conor <conor.walsh@intel.com>; Guo, Jia <jia.guo@intel.com>;
> Yigit, Ferruh <ferruh.yigit@intel.com>; Awal, Mohammad Abdul
> <mohammad.abdul.awal@intel.com>; Doherty, Declan
> <declan.doherty@intel.com>; stable@dpdk.org
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2 1/2] net/ixgbe: fix unchecked return value
> 
> > -----Original Message-----
> > From: Walsh, Conor <conor.walsh@intel.com>
> > Sent: Tuesday, October 20, 2020 18:03
> > To: Guo, Jia <jia.guo@intel.com>; Wang, Haiyue
> > <haiyue.wang@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Awal,
> > Mohammad Abdul <mohammad.abdul.awal@intel.com>; Doherty, Declan
> > <declan.doherty@intel.com>; stable@dpdk.org
> > Cc: dev@dpdk.org; Walsh, Conor <conor.walsh@intel.com>
> > Subject: [PATCH v2 1/2] net/ixgbe: fix unchecked return value
> >
> > The return value of rte_eth_switch_domain_alloc() was not being
> > checked within ixgbe_pf_host_init() which caused a coverity issue. If
> > the call fails a warning is logged using PMD_INIT_LOG() and *vfinfo is free'd.
> > ixgbe_pf_host_init() now has a return value which is checked in
> > eth_ixgbe_dev_init()
> >
> > Coverity issue: 362795
> > Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports")
> >
> > Signed-off-by: Conor Walsh <conor.walsh@intel.com>
> > ---
> >  drivers/net/ixgbe/ixgbe_ethdev.c | 11 +++++++++--
> > drivers/net/ixgbe/ixgbe_ethdev.h |  2 +-
> >  drivers/net/ixgbe/ixgbe_pf.c     | 16 +++++++++++++---
> >  3 files changed, 23 insertions(+), 6 deletions(-)
> 
> Acked-by: Haiyue Wang <haiyue.wang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH v2 2/2] net/ixgbe: remove rte_panic
  2020-10-20 17:06     ` Wang, Haiyue
@ 2020-10-23  0:59       ` Zhang, Qi Z
  0 siblings, 0 replies; 12+ messages in thread
From: Zhang, Qi Z @ 2020-10-23  0:59 UTC (permalink / raw)
  To: Wang, Haiyue, Walsh, Conor, Guo, Jia, Yigit, Ferruh, Awal,
	Mohammad Abdul, Doherty, Declan, stable
  Cc: dev



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Wang, Haiyue
> Sent: Wednesday, October 21, 2020 1:06 AM
> To: Walsh, Conor <conor.walsh@intel.com>; Guo, Jia <jia.guo@intel.com>;
> Yigit, Ferruh <ferruh.yigit@intel.com>; Awal, Mohammad Abdul
> <mohammad.abdul.awal@intel.com>; Doherty, Declan
> <declan.doherty@intel.com>; stable@dpdk.org
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2 2/2] net/ixgbe: remove rte_panic
> 
> > -----Original Message-----
> > From: Walsh, Conor <conor.walsh@intel.com>
> > Sent: Tuesday, October 20, 2020 18:03
> > To: Guo, Jia <jia.guo@intel.com>; Wang, Haiyue
> > <haiyue.wang@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Awal,
> > Mohammad Abdul <mohammad.abdul.awal@intel.com>; Doherty, Declan
> > <declan.doherty@intel.com>; stable@dpdk.org
> > Cc: dev@dpdk.org; Walsh, Conor <conor.walsh@intel.com>
> > Subject: [PATCH v2 2/2] net/ixgbe: remove rte_panic
> >
> > Remove the usage of rte_panic() within ixgbe_pf_host_init()
> >
> > Signed-off-by: Conor Walsh <conor.walsh@intel.com>
> > ---
> >  drivers/net/ixgbe/ixgbe_pf.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> 
> Acked-by: Haiyue Wang <haiyue.wang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
> 
> > --
> > 2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-10-23  1:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 12:26 [dpdk-dev] [PATCH 0/2] net/ixgbe fix unchecked return value and rte_panic Conor Walsh
2020-10-19 12:26 ` [dpdk-dev] [PATCH 1/2] net/ixgbe: fix unchecked return value Conor Walsh
2020-10-20  8:33   ` Wang, Haiyue
2020-10-20  9:07     ` Walsh, Conor
2020-10-19 12:26 ` [dpdk-dev] [PATCH 2/2] net/ixgbe: remove rte_panic Conor Walsh
2020-10-20 10:02 ` [dpdk-dev] [PATCH v2 0/2] net/ixgbe fix unchecked return value and rte_panic Conor Walsh
2020-10-20 10:02   ` [dpdk-dev] [PATCH v2 1/2] net/ixgbe: fix unchecked return value Conor Walsh
2020-10-20 17:05     ` Wang, Haiyue
2020-10-23  0:59       ` Zhang, Qi Z
2020-10-20 10:02   ` [dpdk-dev] [PATCH v2 2/2] net/ixgbe: remove rte_panic Conor Walsh
2020-10-20 17:06     ` Wang, Haiyue
2020-10-23  0:59       ` Zhang, Qi Z

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git