From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: andrew@lunn.ch, hkallweit1@gmail.com, o.rempel@pengutronix.de,
pabeni@redhat.com, netdev@vger.kernel.org, imx@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [RESEND] net: phy: fix NULL pointer dereference in phy_polling_mode()
Date: Wed, 6 Aug 2025 14:01:01 +0100 [thread overview]
Message-ID: <aJNSDeyJn5aZG7xs@shell.armlinux.org.uk> (raw)
In-Reply-To: <ywr5p6ccsbvoxronpzpbtxjqyjlwp5g6ksazbeyh47vmhta6sb@xxl6dzd2hsgg>
On Wed, Aug 06, 2025 at 04:56:58PM +0800, Xu Yang wrote:
> Hi Russell,
>
> On Wed, Aug 06, 2025 at 09:45:01AM +0100, Russell King (Oracle) wrote:
> > On Wed, Aug 06, 2025 at 04:29:31PM +0800, Xu Yang wrote:
> > > Not all phy devices have phy driver attached, so fix the NULL pointer
> > > dereference issue in phy_polling_mode() which was observed on USB net
> > > devices.
> >
> > See my comments in response to your first posting.
>
> Thanks for the comments!
>
> Reproduce step is simple:
>
> 1. connect an USB to Ethernet device to USB port, I'm using "D-Link Corp.
> DUB-E100 Fast Ethernet Adapter".
> 2. the asix driver (drivers/net/usb/asix_devices.c) will bind to this USB
> device.
>
> root@imx95evk:~# lsusb -t
> /: Bus 001.Port 001: Dev 001, Class=root_hub, Driver=ci_hdrc/1p, 480M
> |__ Port 001: Dev 003, If 0, Class=Vendor Specific Class, Driver=asix, 480M
>
> 3. then the driver will create many mdio devices.
>
> root@imx95evk:/sys/bus/mdio_bus# ls -d devices/usb*
> devices/usb-001:005:00 devices/usb-001:005:04 devices/usb-001:005:08 devices/usb-001:005:0c devices/usb-001:005:10 devices/usb-001:005:14 devices/usb-001:005:18 devices/usb-001:005:1c
> devices/usb-001:005:01 devices/usb-001:005:05 devices/usb-001:005:09 devices/usb-001:005:0d devices/usb-001:005:11 devices/usb-001:005:15 devices/usb-001:005:19 devices/usb-001:005:1d
> devices/usb-001:005:02 devices/usb-001:005:06 devices/usb-001:005:0a devices/usb-001:005:0e devices/usb-001:005:12 devices/usb-001:005:16 devices/usb-001:005:1a devices/usb-001:005:1e
> devices/usb-001:005:03 devices/usb-001:005:07 devices/usb-001:005:0b devices/usb-001:005:0f devices/usb-001:005:13 devices/usb-001:005:17 devices/usb-001:005:1b devices/usb-001:005:1f
This looks broken - please check what
/sys/bus/mdio_bus/devices/usb*/phy_id contains.
However, this patch should stop the oops. Please test and let me know
whether it works. Thanks.
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 7556aa3dd7ee..e6a673faabe6 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -288,7 +288,7 @@ static bool phy_uses_state_machine(struct phy_device *phydev)
return phydev->attached_dev && phydev->adjust_link;
/* phydev->phy_link_change is implicitly phylink_phy_change() */
- return true;
+ return !!phydev->phy_link_change;
}
static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2025-08-06 13:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 8:29 Xu Yang
2025-08-06 8:45 ` Russell King (Oracle)
2025-08-06 8:56 ` Xu Yang
2025-08-06 13:01 ` Russell King (Oracle) [this message]
2025-08-06 14:14 ` Xu Yang
2025-08-06 15:01 ` Andrew Lunn
2025-08-06 16:47 ` Russell King (Oracle)
2025-08-07 9:23 ` Xu Yang
2025-08-07 11:21 ` Xu Yang
2025-08-07 11:47 ` Russell King (Oracle)
2025-08-07 12:45 ` Oleksij Rempel
2025-08-07 12:58 ` Andrew Lunn
2025-08-07 14:02 ` Oleksij Rempel
2025-08-08 10:26 ` Xu Yang
2025-08-08 10:17 ` Xu Yang
2025-08-07 12:55 ` Andrew Lunn
2025-08-07 9:10 ` Xu Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aJNSDeyJn5aZG7xs@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=hkallweit1@gmail.com \
--cc=imx@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=xu.yang_2@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®