]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ice: add NULL check in eswitch lag check
authorDave Ertman <david.m.ertman@intel.com>
Thu, 22 May 2025 17:16:57 +0000 (13:16 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 24 Jul 2025 06:53:18 +0000 (08:53 +0200)
[ Upstream commit 3ce58b01ada408b372f15b7c992ed0519840e3cf ]

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")
Signed-off-by: Dave Ertman <david.m.ertman@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: Sujai Buvaneswaran <sujai.buvaneswaran@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/intel/ice/ice_lag.c

index 4db0b770420e651df53fa1b5da67c4d3f1aaedf9..8ed9918ea4e894786fe93cf3eb6ec48e67aa87a4 100644 (file)
@@ -2129,7 +2129,8 @@ bool ice_lag_is_switchdev_running(struct ice_pf *pf)
        struct ice_lag *lag = pf->lag;
        struct net_device *tmp_nd;
 
-       if (!ice_is_feature_supported(pf, ICE_F_SRIOV_LAG) || !lag)
+       if (!ice_is_feature_supported(pf, ICE_F_SRIOV_LAG) ||
+           !lag || !lag->upper_netdev)
                return false;
 
        rcu_read_lock();