[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251101-k1-ethernet-remove-fc-v2-1-014ac3bc280e@iscas.ac.cn>
Date: Sat, 01 Nov 2025 02:28:04 +0800
From: Vivian Wang <wangruikang@...as.ac.cn>
To: Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Yixun Lan <dlan@...too.org>,
Maxime Chevallier <maxime.chevallier@...tlin.com>,
Troy Mitchell <troy.mitchell@...ux.spacemit.com>,
Vadim Fedorenko <vadim.fedorenko@...ux.dev>,
Vivian Wang <wangruikang@...as.ac.cn>
Cc: netdev@...r.kernel.org, linux-riscv@...ts.infradead.org,
spacemit@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: [PATCH net v2] net: spacemit: Check IFF_UP 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 IFF_UP in emac_set_pauseparam() before proceeding.
Fixes: bfec6d7f2001 ("net: spacemit: Add K1 Ethernet MAC")
Signed-off-by: Vivian Wang <wangruikang@...as.ac.cn>
---
Changes in v2:
- Reduced patch to only contain checking IFF_UP to avoid the oops. More
invasive changes will be sent to net-next in the future. (Andrew)
- Link to v1: https://lore.kernel.org/r/20251031-k1-ethernet-remove-fc-v1-1-1ae3f1d6508c@iscas.ac.cn
---
drivers/net/ethernet/spacemit/k1_emac.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/spacemit/k1_emac.c b/drivers/net/ethernet/spacemit/k1_emac.c
index e1c5faff3b71..a3fc17d2ca10 100644
--- a/drivers/net/ethernet/spacemit/k1_emac.c
+++ b/drivers/net/ethernet/spacemit/k1_emac.c
@@ -1441,6 +1441,9 @@ static int emac_set_pauseparam(struct net_device *dev,
struct emac_priv *priv = netdev_priv(dev);
u8 fc = 0;
+ if (!(dev->flags & IFF_UP))
+ return -ENETDOWN;
+
priv->flow_control_autoneg = pause->autoneg;
if (pause->autoneg) {
---
base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
change-id: 20251031-k1-ethernet-remove-fc-82fd67d889a6
Best regards,
--
Vivian "dramforever" Wang
Powered by blists - more mailing lists