Skip to contentSkip to conversation

ice: add NULL check in eswitch lag check

PATCH In review Dave Ertman 3 participants 3 messages May 22, 2025 – Jul 11, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ice: add NULL check in eswitch lag check

The function ice_lag_is_switchdev_running() is being called from outside of the LAG event handler code. This results in the lag->upper_netdev being NULL sometimes. To avoid a NULL-pointer dereference, there needs to be a check before it is dereferenced.

Fixes 776fe19953b0 ("ice: block default rule setting on LAG interface")
---
 drivers/net/ethernet/intel/ice/ice_lag.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ice/ice_lag.c +3 -0
index c5e3ada4746c..e22f2e5a3b19 100644
@@ -2798,6 +2798,9 @@ bool ice_lag_is_switchdev_running(struct ice_pf *pf)
 	if (!ice_is_feature_supported(pf, ICE_F_SRIOV_LAG) || !lag)
 		return false;
 
+	if (!lag->upper_netdev)
+		return false;
+
 	rcu_read_lock();
 	for_each_netdev_in_bond_rcu(lag->upper_netdev, tmp_nd) {
 		struct ice_netdev_priv *priv = netdev_priv(tmp_nd);
Signature · 1 line
2.49.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Dave Ertman
Sent: Thursday, May 22, 2025 7:17 PM
To: [email protected]
Subject: [Intel-wired-lan] [PATCH iwl-net v2] ice: add NULL check in eswitch lag check

Quoted 8 lines

The function ice_lag_is_switchdev_running() is being called from outside of the LAG event handler code. This results in the lag-

Quoted 1 line

upper_netdev being NULL sometimes. To avoid a NULL-pointer

dereference, there needs to be a check before it is dereferenced.

Fixes 776fe19953b0 ("ice: block default rule setting on LAG

interface")

Quoted 22 lines
---
 drivers/net/ethernet/intel/ice/ice_lag.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/ice/ice_lag.c +3 -0
index c5e3ada4746c..e22f2e5a3b19 100644
@@ -2798,6 +2798,9 @@ bool ice_lag_is_switchdev_running(struct ice_pf
 *pf)
 	if (!ice_is_feature_supported(pf, ICE_F_SRIOV_LAG) || !lag)
 		return false;
 
+	if (!lag->upper_netdev)
+		return false;
+
 	rcu_read_lock();
 	for_each_netdev_in_bond_rcu(lag->upper_netdev, tmp_nd) {

struct ice_netdev_priv *priv = netdev_priv(tmp_nd);
--
2.49.0

Tested-by on v2 1/1
#2 lore raw
In reply to Dave Ertman
Quoted 13 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Dave Ertman
Sent: Thursday, May 22, 2025 10:47 PM
To: [email protected]
Subject: [Intel-wired-lan] [PATCH iwl-net v2] ice: add NULL check in eswitch lag check

The function ice_lag_is_switchdev_running() is being called from outside of the LAG event handler code. This results in the lag->upper_netdev being NULL sometimes. To avoid a NULL-pointer dereference, there needs to be a check before it is dereferenced.

Quoted 6 lines
Fixes 776fe19953b0 ("ice: block default rule setting on LAG interface")
---
 drivers/net/ethernet/intel/ice/ice_lag.c | 3 +++
 1 file changed, 3 insertions(+)