Skip to content

Commit 1f3bd64

Browse files
hkallweitPaolo Abeni
authored andcommitted
net: stmmac: fix invalid call to mdiobus_get_phy()
In a number of cases the driver assigns a default value of -1 to priv->plat->phy_addr. This may result in calling mdiobus_get_phy() with addr parameter being -1. Therefore check for this scenario and bail out before calling mdiobus_get_phy(). Fixes: 42e8702 ("net: stmmac: Fix case when PHY handle is not present") Signed-off-by: Heiner Kallweit <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 867dbe7 commit 1f3bd64

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,11 @@ static int stmmac_init_phy(struct net_device *dev)
11501150
int addr = priv->plat->phy_addr;
11511151
struct phy_device *phydev;
11521152

1153+
if (addr < 0) {
1154+
netdev_err(priv->dev, "no phy found\n");
1155+
return -ENODEV;
1156+
}
1157+
11531158
phydev = mdiobus_get_phy(priv->mii, addr);
11541159
if (!phydev) {
11551160
netdev_err(priv->dev, "no phy at addr %d\n", addr);

0 commit comments

Comments
 (0)