Skip to content

Commit

Permalink
net: phy: bcm84881: Fix some error handling paths
Browse files Browse the repository at this point in the history
If phy_read_mmd() fails, the error code stored in 'bmsr' should be returned
instead of 'val' which is likely to be 0.

Fixes: 75f4d8d ("net: phy: add Broadcom BCM84881 PHY driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/3e1755b0c40340d00e089d6adae5bca2f8c79e53.1727982168.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Christophe JAILLET authored and Jakub Kicinski committed Oct 4, 2024
1 parent 1dae9f1 commit 9234a25
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/phy/bcm84881.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static int bcm84881_aneg_done(struct phy_device *phydev)

bmsr = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_C22 + MII_BMSR);
if (bmsr < 0)
return val;
return bmsr;

return !!(val & MDIO_AN_STAT1_COMPLETE) &&
!!(bmsr & BMSR_ANEGCOMPLETE);
Expand All @@ -158,7 +158,7 @@ static int bcm84881_read_status(struct phy_device *phydev)

bmsr = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_C22 + MII_BMSR);
if (bmsr < 0)
return val;
return bmsr;

phydev->autoneg_complete = !!(val & MDIO_AN_STAT1_COMPLETE) &&
!!(bmsr & BMSR_ANEGCOMPLETE);
Expand Down

0 comments on commit 9234a25

Please sign in to comment.