Message ID | 20250129183638.695010-1-sreedevi.joshi@intel.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] phy: fix null pointer issue in phy_attach_direct() | expand |
On Wed, Jan 29, 2025 at 12:36:38PM -0600, sreedevi.joshi wrote: > From: Sreedevi Joshi <sreedevi.joshi@intel.com> > > When attaching a fixed phy to devices like veth Humm. Zoom out. What is the big picture? Why would a veth need a PHY? Andrew
On Wed, Jan 29, 2025 at 12:36:38PM -0600, sreedevi.joshi wrote: > From: Sreedevi Joshi <sreedevi.joshi@intel.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. Kernel mode doesn't segfault. That's a userspace thing. Kernel mode oopses. I'm confused. You mention veth, which presumably is drivers/net/veth.c. Grepping this driver for "phy" returns nothing. So how can veth be broken by a phylib change?
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");