summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorColin Foster <colin.foster@in-advantage.com>2023-01-27 20:14:27 +0300
committerDavid S. Miller <davem@davemloft.net>2023-01-30 12:24:15 +0300
commit73a876022273cbc9c1db7869a54444ce8b9d085e (patch)
tree0fb5a577deee919ebb151cfe48f2bf37b4d52580 /drivers/net
parent611792920925fb088ddccbe2783c7f92fdfb6b64 (diff)
downloadlinux-73a876022273cbc9c1db7869a54444ce8b9d085e.tar.xz
net: phy: fix null dereference in phy_attach_direct
Commit bc66fa87d4fd ("net: phy: Add link between phy dev and mac dev") introduced a link between net devices and phy devices. It fails to check whether dev is NULL, leading to a NULL dereference error. Fixes: bc66fa87d4fd ("net: phy: Add link between phy dev and mac dev") Signed-off-by: Colin Foster <colin.foster@in-advantage.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/phy/phy_device.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 716870a4499c..607aa786c8cb 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1517,7 +1517,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
* another mac interface, so we should create a device link between
* phy dev and mac dev.
*/
- if (phydev->mdio.bus->parent && dev->dev.parent != phydev->mdio.bus->parent)
+ if (dev && phydev->mdio.bus->parent && dev->dev.parent != phydev->mdio.bus->parent)
phydev->devlink = device_link_add(dev->dev.parent, &phydev->mdio.dev,
DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS);