Skip to content

Commit 5556f23

Browse files
dramforeverkuba-moo
authored andcommitted
net: spacemit: Check netif_running() in emac_set_pauseparam()
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: bfec6d7 ("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>
1 parent 2e25935 commit 5556f23

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/net/ethernet/spacemit/k1_emac.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,9 @@ static int emac_set_pauseparam(struct net_device *dev,
14411441
struct emac_priv *priv = netdev_priv(dev);
14421442
u8 fc = 0;
14431443

1444+
if (!netif_running(dev))
1445+
return -ENETDOWN;
1446+
14441447
priv->flow_control_autoneg = pause->autoneg;
14451448

14461449
if (pause->autoneg) {

0 commit comments

Comments
 (0)