Message ID | 20170822212647.11520-1-f.fainelli@gmail.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
From: Florian Fainelli <f.fainelli@gmail.com> Date: Tue, 22 Aug 2017 14:26:47 -0700 > Priit reported that stmmac was crashing with the trace below. This is because > phy_attached_print() is called too early right after the PHY device has been > found, but before it has a driver attached, since that is only done in > phy_probe() which occurs later. > > Fix this by dealing with a possibly NULL phydev->drv point since that can > happen here, but could also happen if we voluntarily did an unbind of the > PHY device with the PHY driver. ... > Tested-By: Priit Laes <plaes@plaes.org> > Fixes: fbca164776e4 ("net: stmmac: Use the right logging function in stmmac_mdio_register") > Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> "net-next"? The commit which introduced this problem is in 'net', don't we want to fix it there?
On 08/22/2017 02:44 PM, David Miller wrote: > From: Florian Fainelli <f.fainelli@gmail.com> > Date: Tue, 22 Aug 2017 14:26:47 -0700 > >> Priit reported that stmmac was crashing with the trace below. This is because >> phy_attached_print() is called too early right after the PHY device has been >> found, but before it has a driver attached, since that is only done in >> phy_probe() which occurs later. >> >> Fix this by dealing with a possibly NULL phydev->drv point since that can >> happen here, but could also happen if we voluntarily did an unbind of the >> PHY device with the PHY driver. > ... >> Tested-By: Priit Laes <plaes@plaes.org> >> Fixes: fbca164776e4 ("net: stmmac: Use the right logging function in stmmac_mdio_register") >> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> > > "net-next"? The commit which introduced this problem is in 'net', don't we want > to fix it there? Oh yes we do, somehow I thought the commit was just in "net-next" hence the subject, the patch applies cleanly to "net" as well. Thanks!
From: Florian Fainelli <f.fainelli@gmail.com> Date: Tue, 22 Aug 2017 14:45:44 -0700 > On 08/22/2017 02:44 PM, David Miller wrote: >> From: Florian Fainelli <f.fainelli@gmail.com> >> Date: Tue, 22 Aug 2017 14:26:47 -0700 >> >>> Priit reported that stmmac was crashing with the trace below. This is because >>> phy_attached_print() is called too early right after the PHY device has been >>> found, but before it has a driver attached, since that is only done in >>> phy_probe() which occurs later. >>> >>> Fix this by dealing with a possibly NULL phydev->drv point since that can >>> happen here, but could also happen if we voluntarily did an unbind of the >>> PHY device with the PHY driver. >> ... >>> Tested-By: Priit Laes <plaes@plaes.org> >>> Fixes: fbca164776e4 ("net: stmmac: Use the right logging function in stmmac_mdio_register") >>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> >> >> "net-next"? The commit which introduced this problem is in 'net', don't we want >> to fix it there? > > Oh yes we do, somehow I thought the commit was just in "net-next" hence > the subject, the patch applies cleanly to "net" as well. I thought so, thanks for clarifying. Applied.
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 9493fb369682..810f6fd2f639 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -877,15 +877,17 @@ EXPORT_SYMBOL(phy_attached_info); #define ATTACHED_FMT "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)" void phy_attached_print(struct phy_device *phydev, const char *fmt, ...) { + const char *drv_name = phydev->drv ? phydev->drv->name : "unbound"; + if (!fmt) { dev_info(&phydev->mdio.dev, ATTACHED_FMT "\n", - phydev->drv->name, phydev_name(phydev), + drv_name, phydev_name(phydev), phydev->irq); } else { va_list ap; dev_info(&phydev->mdio.dev, ATTACHED_FMT, - phydev->drv->name, phydev_name(phydev), + drv_name, phydev_name(phydev), phydev->irq); va_start(ap, fmt);