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.

Cc: stable+noautosel@kernel.org # untested fix to unlikely driver error path
Signed-off-by: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Link: https://patch.msgid.link/20260902065828.1031113-1-donggeunyoo.kernel@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Donggeun Yoo 2026-09-02 15:58:27 +09:00 committed by Jakub Kicinski
parent e84b89f17a
commit 8c9190bfd1

View File

@ -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;