All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] net: phy: Check phy_driver ready before accessing
@ 2018-06-07 15:53 Brandon Maier
  2018-06-07 15:53 ` [PATCH 2/3] net: phy: xgmiitorgmii: Use correct mdio bus Brandon Maier
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Brandon Maier @ 2018-06-07 15:53 UTC (permalink / raw)
  To: netdev
  Cc: andrew, f.fainelli, davem, michal.simek, clayton.shotwell,
	kristopher.cory, linux-kernel, Brandon Maier

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 <brandon.maier@rockwellcollins.com>
---
 drivers/net/phy/xilinx_gmii2rgmii.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c
index 2e5150b0b8d5..04c8bec1c4c1 100644
--- a/drivers/net/phy/xilinx_gmii2rgmii.c
+++ b/drivers/net/phy/xilinx_gmii2rgmii.c
@@ -81,6 +81,11 @@ static int xgmiitorgmii_probe(struct mdio_device *mdiodev)
 		return -EPROBE_DEFER;
 	}
 
+	if (!priv->phy_dev->drv) {
+		dev_info(dev, "Attached phy not ready\n");
+		return -EPROBE_DEFER;
+	}
+
 	priv->addr = mdiodev->addr;
 	priv->phy_drv = priv->phy_dev->drv;
 	memcpy(&priv->conv_phy_drv, priv->phy_dev->drv,
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-06-07 18:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-07 15:53 [PATCH 1/3] net: phy: Check phy_driver ready before accessing Brandon Maier
2018-06-07 15:53 ` [PATCH 2/3] net: phy: xgmiitorgmii: Use correct mdio bus Brandon Maier
2018-06-07 16:49   ` Andrew Lunn
2018-06-07 17:37     ` Brandon Maier
2018-06-07 15:53 ` [PATCH 3/3] net: phy: xgmiitorgmii: Check read_status results Brandon Maier
2018-06-07 16:43   ` Andrew Lunn
2018-06-07 16:52 ` [PATCH 1/3] net: phy: Check phy_driver ready before accessing Andrew Lunn
2018-06-07 17:34   ` Brandon Maier
2018-06-07 18:12     ` Andrew Lunn
2018-06-07 16:54 ` Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.