Since a phy_device is added to the global mdio_bus list during
phy_device_register(), but a phy_device's phy_driver doesn't get
attached until phy_probe(). It's possible of_phy_find_device() in
xgmiitorgmii will return a valid phy with a NULL phy_driver. Leading to
a NULL pointer access during the memcpy().
Signed-off-by: Brandon Maier <redacted>
---
drivers/net/phy/xilinx_gmii2rgmii.c | 5 +++++
1 file changed, 5 insertions(+)
We're ignoring the result of the attached phy device's read_status().
Return it so we can detect errors.
Signed-off-by: Brandon Maier <redacted>
---
drivers/net/phy/xilinx_gmii2rgmii.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
The xgmiitorgmii is using the mii_bus of the device it's attached too,
instead of the bus it was given during probe.
Signed-off-by: Brandon Maier <redacted>
---
drivers/net/phy/xilinx_gmii2rgmii.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
From: Andrew Lunn <andrew@lunn.ch> Date: 2018-06-07 16:52:40
On Thu, Jun 07, 2018 at 10:53:46AM -0500, Brandon Maier wrote:
Since a phy_device is added to the global mdio_bus list during
phy_device_register(), but a phy_device's phy_driver doesn't get
attached until phy_probe(). It's possible of_phy_find_device() in
xgmiitorgmii will return a valid phy with a NULL phy_driver. Leading to
a NULL pointer access during the memcpy().
I'm sure there are more issues like this in the code. e.g. there is
no attempt made to hold a reference to the child phy. So it could be
unbound. priv->phy_drv->read_status(phydev) is then going to do bad
things.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
From: Andrew Lunn <andrew@lunn.ch> Date: 2018-06-07 16:54:15
On Thu, Jun 07, 2018 at 10:53:46AM -0500, Brandon Maier wrote:
Since a phy_device is added to the global mdio_bus list during
phy_device_register(), but a phy_device's phy_driver doesn't get
attached until phy_probe(). It's possible of_phy_find_device() in
xgmiitorgmii will return a valid phy with a NULL phy_driver. Leading to
a NULL pointer access during the memcpy().
Hi Brandon
FYI: net-next is closed at the moment. Please resubmit these in two
weeks time.
Andrew
On Thu, Jun 7, 2018 at 11:52 AM, Andrew Lunn [off-list ref] wrote:
FYI: net-next is closed at the moment. Please resubmit these in two
weeks time.
Ah, I didn't see networking/netdev-FAQ.txt. I'll resubmit these then.
I'm sure there are more issues like this in the code. e.g. there is
no attempt made to hold a reference to the child phy. So it could be
unbound. priv->phy_drv->read_status(phydev) is then going to do bad
things.
Agreed. Another thing that looks suspicious to me is the driver
overrides the private data of the device it's attaching too, in the
`priv->phy_dev->priv = priv` bit. Seems like that could cause all
sorts of driver corruption problems.
But fixing that is going to require more drastic changes to how this
driver works. So it'd be worth applying this patch in the mean time.
From: Andrew Lunn <andrew@lunn.ch> Date: 2018-06-07 18:12:43
Agreed. Another thing that looks suspicious to me is the driver
overrides the private data of the device it's attaching too, in the
`priv->phy_dev->priv = priv` bit. Seems like that could cause all
sorts of driver corruption problems.
Ah, yes. That is very broken. Many PHYs will just explode sometime
later, since they use phdev->priv.
But fixing that is going to require more drastic changes to how this
driver works. So it'd be worth applying this patch in the mean time.