net: phy: dp83848: check phy_read() return value in config_init()
Subsystems (3)
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.
---
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
@@ -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
Hi,
Quoted 10 lines · Donggeun Yoo
dp83848_config_init()reads BMCR to detect whether auto-negotiation is enabled, but does not check thephy_read()return value. On an MDIO read failurephy_read()returns a negative errno, which is then used directly in a bitwise test; the auto-negotiation state is left undefined whileconfig_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")Signed-off-by Donggeun Yoo <[email protected]>
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@@ -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
Quoted 10 lines · Donggeun Yoo
dp83848_config_init()reads BMCR to detect whether auto-negotiation is enabled, but does not check thephy_read()return value. On an MDIO read failurephy_read()returns a negative errno, which is then used directly in a bitwise test; the auto-negotiation state is left undefined whileconfig_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")Signed-off-by Donggeun Yoo <[email protected]>
Thanks,
Xuanqiang
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 thephy_read()return value. On an MDIO read failurephy_read()returns a negative errno, which is then used directly in a bitwise test; the auto-negotiation state is left undefined whileconfig_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