]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: spacemit: Check netif_running() in emac_set_pauseparam()
authorVivian Wang <wangruikang@iscas.ac.cn>
Mon, 3 Nov 2025 02:02:49 +0000 (10:02 +0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 4 Nov 2025 01:23:48 +0000 (17:23 -0800)
Currently, emac_set_pauseparam() will oops if userspace calls it while
the interface is not up, because phydev is NULL, but it is still
accessed in emac_set_fc() and emac_set_fc_autoneg().

Check for netif_running(dev) in emac_set_pauseparam() before proceeding.

Fixes: bfec6d7f2001 ("net: spacemit: Add K1 Ethernet MAC")
Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20251103-k1-ethernet-remove-fc-v3-1-2083770cd282@iscas.ac.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/spacemit/k1_emac.c

index e1c5faff3b71c7d4ceba2ea194d9c888f0e71b70..220eb5ce75833d9f345be7f68347e358f879e9e4 100644 (file)
@@ -1441,6 +1441,9 @@ static int emac_set_pauseparam(struct net_device *dev,
        struct emac_priv *priv = netdev_priv(dev);
        u8 fc = 0;
 
+       if (!netif_running(dev))
+               return -ENETDOWN;
+
        priv->flow_control_autoneg = pause->autoneg;
 
        if (pause->autoneg) {