diff mbox series

[v3] net/ice: fix representor port segmentation fault

Message ID 20210907020033.2113437-1-dapengx.yu@intel.com (mailing list archive)
State Accepted
Delegated to: Qi Zhang
Headers show
Series [v3] net/ice: fix representor port segmentation fault | expand

Checks

Context Check Description
ci/intel-Testing fail Testing issues
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Performance fail Performance Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/checkpatch success coding style OK

Commit Message

Yu, DapengX Sept. 7, 2021, 2 a.m. UTC
From: Dapeng Yu <dapengx.yu@intel.com>

If DCF representor port is closed after DCF port is closed, there will
be segmentation fault because representor accesses the released resource
of DCF port.

This patch checks if the resource is present before accessing.

Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling")
Cc: stable@dpdk.org

Signed-off-by: Dapeng Yu <dapengx.yu@intel.com>
---
V2:
 * Remove (void) to make code clean.
V3:
 * Only check resource accessibility but not release it.
---
 drivers/net/ice/ice_dcf_vf_representor.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Wang, Haiyue Sept. 13, 2021, 5:46 a.m. UTC | #1
> -----Original Message-----
> From: Yu, DapengX <dapengx.yu@intel.com>
> Sent: Tuesday, September 7, 2021 10:01
> To: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org; Wang, Haiyue <haiyue.wang@intel.com>; Yu, DapengX <dapengx.yu@intel.com>;
> stable@dpdk.org
> Subject: [PATCH v3] net/ice: fix representor port segmentation fault
> 
> From: Dapeng Yu <dapengx.yu@intel.com>
> 
> If DCF representor port is closed after DCF port is closed, there will
> be segmentation fault because representor accesses the released resource
> of DCF port.
> 
> This patch checks if the resource is present before accessing.
> 
> Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dapeng Yu <dapengx.yu@intel.com>
> ---
> V2:
>  * Remove (void) to make code clean.
> V3:
>  * Only check resource accessibility but not release it.
> ---
>  drivers/net/ice/ice_dcf_vf_representor.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 

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

> --
> 2.27.0
Zhang, Qi Z Sept. 13, 2021, 5:50 a.m. UTC | #2
> -----Original Message-----
> From: Wang, Haiyue <haiyue.wang@intel.com>
> Sent: Monday, September 13, 2021 1:47 PM
> To: Yu, DapengX <dapengx.yu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: RE: [PATCH v3] net/ice: fix representor port segmentation fault
> 
> > -----Original Message-----
> > From: Yu, DapengX <dapengx.yu@intel.com>
> > Sent: Tuesday, September 7, 2021 10:01
> > To: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> > <qi.z.zhang@intel.com>
> > Cc: dev@dpdk.org; Wang, Haiyue <haiyue.wang@intel.com>; Yu, DapengX
> > <dapengx.yu@intel.com>; stable@dpdk.org
> > Subject: [PATCH v3] net/ice: fix representor port segmentation fault
> >
> > From: Dapeng Yu <dapengx.yu@intel.com>
> >
> > If DCF representor port is closed after DCF port is closed, there will
> > be segmentation fault because representor accesses the released
> > resource of DCF port.
> >
> > This patch checks if the resource is present before accessing.
> >
> > Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Dapeng Yu <dapengx.yu@intel.com>
> > ---
> > V2:
> >  * Remove (void) to make code clean.
> > V3:
> >  * Only check resource accessibility but not release it.
> > ---
> >  drivers/net/ice/ice_dcf_vf_representor.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> 
> Acked-by: Haiyue Wang <haiyue.wang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi

> 
> > --
> > 2.27.0
>
diff mbox series

Patch

diff --git a/drivers/net/ice/ice_dcf_vf_representor.c b/drivers/net/ice/ice_dcf_vf_representor.c
index 970461f3e9..b547c42f91 100644
--- a/drivers/net/ice/ice_dcf_vf_representor.c
+++ b/drivers/net/ice/ice_dcf_vf_representor.c
@@ -114,6 +114,11 @@  ice_dcf_vf_repr_hw(struct ice_dcf_vf_repr *repr)
 	struct ice_dcf_adapter *dcf_adapter =
 			repr->dcf_eth_dev->data->dev_private;
 
+	if (!dcf_adapter) {
+		PMD_DRV_LOG(ERR, "DCF for VF representor has been released\n");
+		return NULL;
+	}
+
 	return &dcf_adapter->real_hw;
 }
 
@@ -124,6 +129,9 @@  ice_dcf_vf_repr_dev_info_get(struct rte_eth_dev *dev,
 	struct ice_dcf_vf_repr *repr = dev->data->dev_private;
 	struct ice_dcf_hw *dcf_hw = ice_dcf_vf_repr_hw(repr);
 
+	if (!dcf_hw)
+		return -EIO;
+
 	dev_info->device = dev->device;
 	dev_info->max_mac_addrs = 1;
 	dev_info->max_rx_queues = dcf_hw->vsi_res->num_queue_pairs;