Patch "net: stmmac: fix invalid call to mdiobus_get_phy()" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: stmmac: fix invalid call to mdiobus_get_phy()

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-stmmac-fix-invalid-call-to-mdiobus_get_phy.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d292bf3e481d9ea229c31a0f842d690a90ac5321
Author: Heiner Kallweit <hkallweit1@xxxxxxxxx>
Date:   Sun Jan 15 18:24:08 2023 +0100

    net: stmmac: fix invalid call to mdiobus_get_phy()
    
    [ Upstream commit 1f3bd64ad921f051254591fbed04fd30b306cde6 ]
    
    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: 42e87024f727 ("net: stmmac: Fix case when PHY handle is not present")
    Signed-off-by: Heiner Kallweit <hkallweit1@xxxxxxxxx>
    Link: https://lore.kernel.org/r/669f9671-ecd1-a41b-2727-7b73e3003985@xxxxxxxxx
    Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 9931724c4727..3079e5254666 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -998,6 +998,11 @@ static int stmmac_init_phy(struct net_device *dev)
 		int addr = priv->plat->phy_addr;
 		struct phy_device *phydev;
 
+		if (addr < 0) {
+			netdev_err(priv->dev, "no phy found\n");
+			return -ENODEV;
+		}
+
 		phydev = mdiobus_get_phy(priv->mii, addr);
 		if (!phydev) {
 			netdev_err(priv->dev, "no phy at addr %d\n", addr);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux