On Fri, May 24, 2019 at 01:04:01AM +0300, Vladimir Oltean wrote: > On Fri, 24 May 2019 at 00:55, Russell King - ARM Linux admin > <li...@armlinux.org.uk> wrote: > > > > On Thu, May 23, 2019 at 01:20:40AM +0000, Ioana Ciornei wrote: > > > + if (pl->ops) { > > > + pl->ops->mac_link_up(ndev, pl->link_an_mode, > > > pl->phy_state.interface, > > > pl->phydev); > > > > > > + netif_carrier_on(ndev); > > > > > > + netdev_info(ndev, > > > + "Link is Up - %s/%s - flow control %s\n", > > > + phy_speed_to_str(link_state.speed), > > > + phy_duplex_to_str(link_state.duplex), > > > + phylink_pause_to_str(link_state.pause)); > > > + } else { > > > + blocking_notifier_call_chain(&pl->notifier_chain, > > > + PHYLINK_MAC_LINK_UP, &info); > > > + phydev_info(pl->phydev, > > > + "Link is Up - %s/%s - flow control %s\n", > > > + phy_speed_to_str(link_state.speed), > > > + phy_duplex_to_str(link_state.duplex), > > > + phylink_pause_to_str(link_state.pause)); > > > + } > > > > So if we don't have pl->ops, what happens when we call phydev_info() > > with a NULL phydev, which is a very real possibility: one of phylink's > > whole points is to support dynamic presence of a PHY. > > > > What will happen in that case is this will oops, due to dereferencing > > an offset NULL pointer via: > > > > #define phydev_info(_phydev, format, args...) \ > > dev_info(&_phydev->mdio.dev, format, ##args) > > > > You can't just decide that if there's no netdev, we will be guaranteed > > a phy. > > > > -- > > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > > FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps > > up > > According to speedtest.net: 11.9Mbps down 500kbps up > > True, however it does not crash: > > [ 2.539949] (NULL device *): Link is Up - 1Gbps/Full - flow control off > > I agree that a better printing system has to be established though.
The only reason that happens is because struct mdio_device is at the start of struct phy_device, and struct device is at the start of struct mdio_device. Should either of these move, that breaks and we get an oops. Sorry, that's way too fragile. Plus, of course, do we think that printing "(NULL device *):" is really acceptable? We completely lose any information about _what_ link came up or went down. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up