Skip to contentSkip to conversation

net: phy: dp83848: check phy_read() return value in config_init()

PATCH Applied Donggeun Yoo 4 participants 4 messages Sep 2 – Sep 4

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

PATCH 1/1 net: phy: dp83848: check phy_read() return value in config_init()

dp83848_config_init() reads BMCR to detect whether auto-negotiation is enabled, but does not check the phy_read() return value. On an MDIO read failure phy_read() returns a negative errno, which is then used directly in a bitwise test; the auto-negotiation state is left undefined while config_init() still reports success.

Check the return value and propagate the error.

Fixes b718e8c8f4f5 ("net: phy: dp83822: use BMCR_ANENABLE instead of BMSR_ANEGCAPABLE for DP83620")

---
Only compile-tested; I do not have DP83848-family hardware.

 drivers/net/phy/dp83848.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/phy/dp83848.c +3 -0
index d88b1999d596..e65651ac567a 100644
@@ -117,6 +117,9 @@ static int dp83848_config_init(struct phy_device *phydev)
 	 * we check initial value of BMCR Auto negotiation enable bit
 	 */
 	val = phy_read(phydev, MII_BMCR);
+	if (val < 0)
+		return val;
+
 	if (!(val & BMCR_ANENABLE))
 		phydev->autoneg = AUTONEG_DISABLE;
 

base-commit: 70f3995830d3f1e79faa14eb0605914f778feca9

Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 10 lines · Donggeun Yoo

dp83848_config_init() reads BMCR to detect whether auto-negotiation is enabled, but does not check the phy_read() return value. On an MDIO read failure phy_read() returns a negative errno, which is then used directly in a bitwise test; the auto-negotiation state is left undefined while config_init() still reports success.

Check the return value and propagate the error.

Fixes b718e8c8f4f5 ("net: phy: dp83822: use BMCR_ANENABLE instead of BMSR_ANEGCAPABLE for DP83620")

Maxime

Quoted 22 lines

---
Only compile-tested; I do not have DP83848-family hardware.

 drivers/net/phy/dp83848.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/phy/dp83848.c +3 -0
index d88b1999d596..e65651ac567a 100644
@@ -117,6 +117,9 @@ static int dp83848_config_init(struct phy_device *phydev)
 	 * we check initial value of BMCR Auto negotiation enable bit
 	 */
 	val = phy_read(phydev, MII_BMCR);
+	if (val < 0)
+		return val;
+
 	if (!(val & BMCR_ANENABLE))
 		phydev->autoneg = AUTONEG_DISABLE;
 

base-commit: 70f3995830d3f1e79faa14eb0605914f778feca9

Reviewed-by on v1 1/1
#2 lore raw
In reply to Donggeun Yoo
Quoted 10 lines · Donggeun Yoo

dp83848_config_init() reads BMCR to detect whether auto-negotiation is enabled, but does not check the phy_read() return value. On an MDIO read failure phy_read() returns a negative errno, which is then used directly in a bitwise test; the auto-negotiation state is left undefined while config_init() still reports success.

Check the return value and propagate the error.

Fixes b718e8c8f4f5 ("net: phy: dp83822: use BMCR_ANENABLE instead of BMSR_ANEGCAPABLE for DP83620")

Thanks,
Xuanqiang

#3 lore raw
In reply to Donggeun Yoo
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Wed, 2 Sep 2026 15:58:27 +0900 you wrote:

dp83848_config_init() reads BMCR to detect whether auto-negotiation is enabled, but does not check the phy_read() return value. On an MDIO read failure phy_read() returns a negative errno, which is then used directly in a bitwise test; the auto-negotiation state is left undefined while config_init() still reports success.

Check the return value and propagate the error.

[...]

Here is the summary with links:
- [net] net: phy: dp83848: check phy_read() return value in config_init()

    https://git.kernel.org/netdev/net-next/c/8c9190bfd18a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html