Skip to contentSkip to conversation

net/ice: fix representor port segmentation fault

PATCH Superseded [email protected] 3 participants 8 messages Sep 2, 2021 – Sep 13, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ice: fix representor port segmentation fault

From: Dapeng Yu <[email protected]>

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 makes DCF representor port is always closed before DCF port is closed.

Fixes 5674465a32c8 ("net/ice: add DCF VLAN handling")
---
 drivers/net/ice/ice_dcf_ethdev.c         |  1 +
 drivers/net/ice/ice_dcf_ethdev.h         |  1 +
 drivers/net/ice/ice_dcf_vf_representor.c | 26 ++++++++++++++++++++----
 3 files changed, 24 insertions(+), 4 deletions(-)
drivers/net/ice/ice_dcf_ethdev.c +1 -0
index cab7c4da87..b837f69fd4 100644
@@ -874,6 +874,7 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	ice_dcf_vf_repr_close_all(adapter);
 	ice_dcf_free_repr_info(adapter);
 	ice_dcf_uninit_parent_adapter(dev);
 	ice_dcf_uninit_hw(dev, &adapter->real_hw);
drivers/net/ice/ice_dcf_ethdev.h +1 -0
index 8510e37119..9e8d3ef0c5 100644
@@ -64,5 +64,6 @@ int ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, void *init_param);
 int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev);
 int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev);
 void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter);
+void ice_dcf_vf_repr_close_all(struct ice_dcf_adapter *dcf_adapter);
 
 #endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_vf_representor.c +22 -4
index 970461f3e9..121dea7483 100644
@@ -46,6 +46,7 @@ static int
 ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
 {
 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
+	dev->data->dev_started = 0;
 
 	return 0;
 }
@@ -53,6 +54,7 @@ ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
 static int
 ice_dcf_vf_repr_dev_close(struct rte_eth_dev *dev)
 {
+	(void)ice_dcf_vf_repr_dev_stop(dev);
 	return ice_dcf_vf_repr_uninit(dev);
 }
 
@@ -464,7 +466,6 @@ void
 ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter)
 {
 	uint16_t vf_id;
-	int ret;
 
 	if (!dcf_adapter->repr_infos)
 		return;
@@ -475,8 +476,25 @@ ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter)
 		if (!vf_rep_eth_dev || vf_rep_eth_dev->data->dev_started == 0)
 			continue;
 
-		ret = ice_dcf_vf_repr_dev_stop(vf_rep_eth_dev);
-		if (!ret)
-			vf_rep_eth_dev->data->dev_started = 0;
+		(void)ice_dcf_vf_repr_dev_stop(vf_rep_eth_dev);
+	}
+}
+
+void
+ice_dcf_vf_repr_close_all(struct ice_dcf_adapter *dcf_adapter)
+{
+	uint16_t vf_id;
+
+	if (!dcf_adapter->repr_infos)
+		return;
+
+	for (vf_id = 0; vf_id < dcf_adapter->real_hw.num_vfs; vf_id++) {
+		struct rte_eth_dev *vf_rep_eth_dev =
+				dcf_adapter->repr_infos[vf_id].vf_rep_eth_dev;
+		if (!vf_rep_eth_dev)
+			continue;
+
+		(void)ice_dcf_vf_repr_dev_close(vf_rep_eth_dev);
+		(void)rte_eth_dev_release_port(vf_rep_eth_dev);
 	}
 }
Signature · 1 line
2.27.0
#1 lore raw
Quoted 63 lines

-----Original Message-----
From: Yu, DapengX <[email protected]>
Sent: Thursday, September 2, 2021 17:44
To: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wang, Haiyue <[email protected]>; Yu, DapengX <[email protected]>; [email protected]
Subject: [PATCH] net/ice: fix representor port segmentation fault

From: Dapeng Yu <[email protected]>

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 makes DCF representor port is always closed before DCF port is closed.

Fixes 5674465a32c8 ("net/ice: add DCF VLAN handling")
---
 drivers/net/ice/ice_dcf_ethdev.c         |  1 +
 drivers/net/ice/ice_dcf_ethdev.h         |  1 +
 drivers/net/ice/ice_dcf_vf_representor.c | 26 ++++++++++++++++++++----
 3 files changed, 24 insertions(+), 4 deletions(-)
drivers/net/ice/ice_dcf_ethdev.c +1 -0
index cab7c4da87..b837f69fd4 100644
@@ -874,6 +874,7 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	ice_dcf_vf_repr_close_all(adapter);
 	ice_dcf_free_repr_info(adapter);
 	ice_dcf_uninit_parent_adapter(dev);
 	ice_dcf_uninit_hw(dev, &adapter->real_hw);
drivers/net/ice/ice_dcf_ethdev.h +1 -0
index 8510e37119..9e8d3ef0c5 100644
@@ -64,5 +64,6 @@ int ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, void *init_param);
 int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev);
 int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev);
 void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter);
+void ice_dcf_vf_repr_close_all(struct ice_dcf_adapter *dcf_adapter);
 
 #endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_vf_representor.c +1 -0
index 970461f3e9..121dea7483 100644
@@ -46,6 +46,7 @@ static int
 ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
 {
 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
+	dev->data->dev_started = 0;
 
 	return 0;
 }

drivers/net/ice/ice_dcf_vf_representor.c ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev) · line 57

Quoted 4 lines
drivers/net/ice/ice_dcf_vf_representor.c +1 -0
@@ -53,6 +54,7 @@ ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
 static int
 ice_dcf_vf_repr_dev_close(struct rte_eth_dev *dev)
 {
+	(void)ice_dcf_vf_repr_dev_stop(dev);

Do we truly need the "(void)" ?

Quoted 42 lines
drivers/net/ice/ice_dcf_vf_representor.c +20 -5
 	return ice_dcf_vf_repr_uninit(dev);
 }
 
@@ -464,7 +466,6 @@ void
 ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter)
 {
 	uint16_t vf_id;
-	int ret;
 
 	if (!dcf_adapter->repr_infos)
 		return;
@@ -475,8 +476,25 @@ ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter)
 		if (!vf_rep_eth_dev || vf_rep_eth_dev->data->dev_started == 0)
 			continue;
 
-		ret = ice_dcf_vf_repr_dev_stop(vf_rep_eth_dev);
-		if (!ret)
-			vf_rep_eth_dev->data->dev_started = 0;
+		(void)ice_dcf_vf_repr_dev_stop(vf_rep_eth_dev);
+	}
+}
+
+void
+ice_dcf_vf_repr_close_all(struct ice_dcf_adapter *dcf_adapter)
+{
+	uint16_t vf_id;
+
+	if (!dcf_adapter->repr_infos)
+		return;
+
+	for (vf_id = 0; vf_id < dcf_adapter->real_hw.num_vfs; vf_id++) {
+		struct rte_eth_dev *vf_rep_eth_dev =
+				dcf_adapter->repr_infos[vf_id].vf_rep_eth_dev;
+		if (!vf_rep_eth_dev)
+			continue;
+
+		(void)ice_dcf_vf_repr_dev_close(vf_rep_eth_dev);
+		(void)rte_eth_dev_release_port(vf_rep_eth_dev);
 	}
 }
--

2.27.0

#2 lore raw
Quoted 74 lines

-----Original Message-----
From: Wang, Haiyue <[email protected]>
Sent: Thursday, September 2, 2021 10:45 PM
To: Yu, DapengX <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] net/ice: fix representor port segmentation fault

Quoted 64 lines

-----Original Message-----
From: Yu, DapengX <[email protected]>
Sent: Thursday, September 2, 2021 17:44
To: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wang, Haiyue <[email protected]>; Yu, DapengX <[email protected]>; [email protected]
Subject: [PATCH] net/ice: fix representor port segmentation fault

From: Dapeng Yu <[email protected]>

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 makes DCF representor port is always closed before DCF port is closed.

Fixes 5674465a32c8 ("net/ice: add DCF VLAN handling")
---
 drivers/net/ice/ice_dcf_ethdev.c         |  1 +
 drivers/net/ice/ice_dcf_ethdev.h         |  1 +
 drivers/net/ice/ice_dcf_vf_representor.c | 26
++++++++++++++++++++----
 3 files changed, 24 insertions(+), 4 deletions(-)
drivers/net/ice/ice_dcf_ethdev.c +1 -0
index cab7c4da87..b837f69fd4 100644
@@ -874,6 +874,7 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	ice_dcf_vf_repr_close_all(adapter);
 	ice_dcf_free_repr_info(adapter);
 	ice_dcf_uninit_parent_adapter(dev);
 	ice_dcf_uninit_hw(dev, &adapter->real_hw); diff --git

a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h index 8510e37119..9e8d3ef0c5 100644

drivers/net/ice/ice_dcf_ethdev.h +0 -0
@@ -64,5 +64,6 @@ int ice_dcf_vf_repr_init(struct rte_eth_dev
 *vf_rep_eth_dev, void *init_param);  int ice_dcf_vf_repr_uninit(struct

rte_eth_dev *vf_rep_eth_dev); int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev); void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter);

drivers/net/ice/ice_dcf_ethdev.h +1 -0
+void ice_dcf_vf_repr_close_all(struct ice_dcf_adapter *dcf_adapter);
 
 #endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_vf_representor.c +1 -0
index 970461f3e9..121dea7483 100644
@@ -46,6 +46,7 @@ static int
 ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)  {
 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
+	dev->data->dev_started = 0;
 
Quoted 7 lines

drivers/net/ice/ice_dcf_vf_representor.c ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev) · line 55

Quoted 5 lines
drivers/net/ice/ice_dcf_vf_representor.c +1 -0
 	return 0;
 }
@@ -53,6 +54,7 @@ ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
 static int  ice_dcf_vf_repr_dev_close(struct rte_eth_dev *dev)  {
+	(void)ice_dcf_vf_repr_dev_stop(dev);

Do we truly need the "(void)" ?

Here use (void) to make discarding of return value explicit. There will be no compiler(clang, icc, and gcc) warning even if remove (void) So it is fine without that.

Quoted 44 lines

drivers/net/ice/ice_dcf_vf_representor.c ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter

Quoted 12 lines
drivers/net/ice/ice_dcf_vf_representor.c +0 -1
 	return ice_dcf_vf_repr_uninit(dev);
 }
 
@@ -464,7 +466,6 @@ void
 ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter)  {
 	uint16_t vf_id;
-	int ret;
 
 	if (!dcf_adapter->repr_infos)
 		return;
@@ -475,8 +476,25 @@ ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter

*dcf_adapter)

drivers/net/ice/ice_dcf_vf_representor.c ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter · line 476

Quoted 1 line
drivers/net/ice/ice_dcf_vf_representor.c +0 -0
 		if (!vf_rep_eth_dev || vf_rep_eth_dev->data->dev_started

== 0)

Quoted 29 lines
drivers/net/ice/ice_dcf_vf_representor.c +19 -4
 			continue;
 
-		ret = ice_dcf_vf_repr_dev_stop(vf_rep_eth_dev);
-		if (!ret)
-			vf_rep_eth_dev->data->dev_started = 0;
+		(void)ice_dcf_vf_repr_dev_stop(vf_rep_eth_dev);
+	}
+}
+
+void
+ice_dcf_vf_repr_close_all(struct ice_dcf_adapter *dcf_adapter) {
+	uint16_t vf_id;
+
+	if (!dcf_adapter->repr_infos)
+		return;
+
+	for (vf_id = 0; vf_id < dcf_adapter->real_hw.num_vfs; vf_id++) {
+		struct rte_eth_dev *vf_rep_eth_dev =
+				dcf_adapter-
 repr_infos[vf_id].vf_rep_eth_dev;
+		if (!vf_rep_eth_dev)
+			continue;
+
+		(void)ice_dcf_vf_repr_dev_close(vf_rep_eth_dev);
+		(void)rte_eth_dev_release_port(vf_rep_eth_dev);
 	}
 }
--

2.27.0

#3 lore raw
Quoted 90 lines

-----Original Message-----
From: Yu, DapengX <[email protected]>
Sent: Friday, September 3, 2021 11:09
To: Wang, Haiyue <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] net/ice: fix representor port segmentation fault

Quoted 72 lines

-----Original Message-----
From: Wang, Haiyue <[email protected]>
Sent: Thursday, September 2, 2021 10:45 PM
To: Yu, DapengX <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] net/ice: fix representor port segmentation fault

Quoted 64 lines

-----Original Message-----
From: Yu, DapengX <[email protected]>
Sent: Thursday, September 2, 2021 17:44
To: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wang, Haiyue <[email protected]>; Yu, DapengX <[email protected]>; [email protected]
Subject: [PATCH] net/ice: fix representor port segmentation fault

From: Dapeng Yu <[email protected]>

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 makes DCF representor port is always closed before DCF port is closed.

Fixes 5674465a32c8 ("net/ice: add DCF VLAN handling")
---
 drivers/net/ice/ice_dcf_ethdev.c         |  1 +
 drivers/net/ice/ice_dcf_ethdev.h         |  1 +
 drivers/net/ice/ice_dcf_vf_representor.c | 26
++++++++++++++++++++----
 3 files changed, 24 insertions(+), 4 deletions(-)
drivers/net/ice/ice_dcf_ethdev.c +1 -0
index cab7c4da87..b837f69fd4 100644
@@ -874,6 +874,7 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	ice_dcf_vf_repr_close_all(adapter);
 	ice_dcf_free_repr_info(adapter);
 	ice_dcf_uninit_parent_adapter(dev);
 	ice_dcf_uninit_hw(dev, &adapter->real_hw); diff --git

a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h index 8510e37119..9e8d3ef0c5 100644

drivers/net/ice/ice_dcf_ethdev.h +0 -0
@@ -64,5 +64,6 @@ int ice_dcf_vf_repr_init(struct rte_eth_dev
 *vf_rep_eth_dev, void *init_param);  int ice_dcf_vf_repr_uninit(struct

rte_eth_dev *vf_rep_eth_dev); int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev); void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter);

drivers/net/ice/ice_dcf_ethdev.h +1 -0
+void ice_dcf_vf_repr_close_all(struct ice_dcf_adapter *dcf_adapter);
 
 #endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_vf_representor.c +1 -0
index 970461f3e9..121dea7483 100644
@@ -46,6 +46,7 @@ static int
 ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)  {
 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
+	dev->data->dev_started = 0;
 
Quoted 7 lines

drivers/net/ice/ice_dcf_vf_representor.c ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev) · line 55

Quoted 5 lines
drivers/net/ice/ice_dcf_vf_representor.c +1 -0
 	return 0;
 }
@@ -53,6 +54,7 @@ ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
 static int  ice_dcf_vf_repr_dev_close(struct rte_eth_dev *dev)  {
+	(void)ice_dcf_vf_repr_dev_stop(dev);

Do we truly need the "(void)" ?

Quoted 1 line

Here use (void) to make discarding of return value explicit.

No need so paranoid ;-)

Quoted 2 lines

There will be no compiler(clang, icc, and gcc) warning even if remove (void) So it is fine without that.

Then code is clean.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/net/ice/ice_dcf_vf_representor.c +0 -1
--

2.27.0

#4 lore raw

PATCH v2 1/1 net/ice: fix representor port segmentation fault

In reply to [email protected]

From: Dapeng Yu <[email protected]>

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 makes DCF representor port is always closed before DCF port is closed.

Fixes 5674465a32c8 ("net/ice: add DCF VLAN handling")

---
V2:
* Remove (void) to make code clean

---
 drivers/net/ice/ice_dcf_ethdev.c         |  1 +
 drivers/net/ice/ice_dcf_ethdev.h         |  1 +
 drivers/net/ice/ice_dcf_vf_representor.c | 26 ++++++++++++++++++++----
 3 files changed, 24 insertions(+), 4 deletions(-)
drivers/net/ice/ice_dcf_ethdev.c +1 -0
index cab7c4da87..b837f69fd4 100644
@@ -874,6 +874,7 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
+	ice_dcf_vf_repr_close_all(adapter);
 	ice_dcf_free_repr_info(adapter);
 	ice_dcf_uninit_parent_adapter(dev);
 	ice_dcf_uninit_hw(dev, &adapter->real_hw);
drivers/net/ice/ice_dcf_ethdev.h +1 -0
index 8510e37119..9e8d3ef0c5 100644
@@ -64,5 +64,6 @@ int ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, void *init_param);
 int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev);
 int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev);
 void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter);
+void ice_dcf_vf_repr_close_all(struct ice_dcf_adapter *dcf_adapter);
 
 #endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_vf_representor.c +22 -4
index 970461f3e9..fd9af06c82 100644
@@ -46,6 +46,7 @@ static int
 ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
 {
 	dev->data->dev_link.link_status = ETH_LINK_DOWN;
+	dev->data->dev_started = 0;
 
 	return 0;
 }
@@ -53,6 +54,7 @@ ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev)
 static int
 ice_dcf_vf_repr_dev_close(struct rte_eth_dev *dev)
 {
+	ice_dcf_vf_repr_dev_stop(dev);
 	return ice_dcf_vf_repr_uninit(dev);
 }
 
@@ -464,7 +466,6 @@ void
 ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter)
 {
 	uint16_t vf_id;
-	int ret;
 
 	if (!dcf_adapter->repr_infos)
 		return;
@@ -475,8 +476,25 @@ ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter)
 		if (!vf_rep_eth_dev || vf_rep_eth_dev->data->dev_started == 0)
 			continue;
 
-		ret = ice_dcf_vf_repr_dev_stop(vf_rep_eth_dev);
-		if (!ret)
-			vf_rep_eth_dev->data->dev_started = 0;
+		ice_dcf_vf_repr_dev_stop(vf_rep_eth_dev);
+	}
+}
+
+void
+ice_dcf_vf_repr_close_all(struct ice_dcf_adapter *dcf_adapter)
+{
+	uint16_t vf_id;
+
+	if (!dcf_adapter->repr_infos)
+		return;
+
+	for (vf_id = 0; vf_id < dcf_adapter->real_hw.num_vfs; vf_id++) {
+		struct rte_eth_dev *vf_rep_eth_dev =
+				dcf_adapter->repr_infos[vf_id].vf_rep_eth_dev;
+		if (!vf_rep_eth_dev)
+			continue;
+
+		ice_dcf_vf_repr_dev_close(vf_rep_eth_dev);
+		rte_eth_dev_release_port(vf_rep_eth_dev);
 	}
 }
Signature · 1 line
2.27.0
#5 lore raw

PATCH v3 1/1 net/ice: fix representor port segmentation fault

From: Dapeng Yu <[email protected]>

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")

---
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(+)
drivers/net/ice/ice_dcf_vf_representor.c +8 -0
index 970461f3e9..b547c42f91 100644
@@ -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;
Signature · 1 line
2.27.0
Acked-by on v3 1/1
#6 lore raw
Quoted 20 lines

-----Original Message-----
From: Yu, DapengX <[email protected]>
Sent: Tuesday, September 7, 2021 10:01
To: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wang, Haiyue <[email protected]>; Yu, DapengX <[email protected]>; [email protected]
Subject: [PATCH v3] net/ice: fix representor port segmentation fault

From: Dapeng Yu <[email protected]>

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")
Quoted 9 lines

---
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(+)
Quoted 2 lines

--
2.27.0

Applied
#7 lore raw
Quoted 41 lines

-----Original Message-----
From: Wang, Haiyue <[email protected]>
Sent: Monday, September 13, 2021 1:47 PM
To: Yu, DapengX <[email protected]>; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v3] net/ice: fix representor port segmentation fault

Quoted 21 lines

-----Original Message-----
From: Yu, DapengX <[email protected]>
Sent: Tuesday, September 7, 2021 10:01
To: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Wang, Haiyue <[email protected]>; Yu, DapengX <[email protected]>; [email protected]
Subject: [PATCH v3] net/ice: fix representor port segmentation fault

From: Dapeng Yu <[email protected]>

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")
Quoted 9 lines

---
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(+)
Quoted 1 line

Applied to dpdk-next-net-intel.

Thanks
Qi

Quoted 4 lines
Quoted 3 lines

--
2.27.0