[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250129183638.695010-1-sreedevi.joshi@intel.com>
Date: Wed, 29 Jan 2025 12:36:38 -0600
From: "sreedevi.joshi" <joshisre@...mtp.an.intel.com>
To: andrew@...n.ch,
hkallweit1@...il.com
Cc: linux@...linux.org.uk,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
netdev@...r.kernel.org,
Sreedevi Joshi <sreedevi.joshi@...el.com>
Subject: [PATCH net] phy: fix null pointer issue in phy_attach_direct()
From: Sreedevi Joshi <sreedevi.joshi@...el.com>
When attaching a fixed phy to devices like veth, it is
possible that there is no parent. The logic in
phy_attach_direct() tries to access the driver member
without checking for the null. This causes segfault in the
case of fixed phy.
Checks are in place now to ensure the parent is not null
before accessing to address this scenario.
Fixes: 2db2d9d1ac37 ("net: phy: Guard against the presence of a netdev")
Signed-off-by: Sreedevi Joshi <sreedevi.joshi@...el.com>
---
drivers/net/phy/phy_device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 46713d27412b..be813962cb89 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1471,7 +1471,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
* our own module->refcnt here, otherwise we would not be able to
* unload later on.
*/
- if (dev)
+ if (dev && dev->dev.parent)
ndev_owner = dev->dev.parent->driver->owner;
if (ndev_owner != bus->owner && !try_module_get(bus->owner)) {
phydev_err(phydev, "failed to get the bus module\n");
--
2.25.1
Powered by blists - more mailing lists