From: Andrew Lunn <andrew@lunn.ch>
To: Kimberly Morris <gy770616@gmail.com>
Cc: hkallweit1@gmail.com, linux@armlinux.org.uk,
florian.fainelli@broadcom.com,
bcm-kernel-feedback-list@broadcom.com, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
richardcochran@gmail.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
w@1wt.eu
Subject: Re: [PATCH net 1/2] net: phy: restore timestamping state on probe failure
Date: Thu, 19 Nov 2026 14:23:37 +0100 [thread overview]
Message-ID: <c1075f39-c0b2-44cd-9338-b3506419f685@lunn.ch> (raw)
In-Reply-To: <CAD-64Dfm-2U=1f3b7y3K-B3q_mijQ0xypqUEDt7o+q7Tmxx_hw@mail.gmail.com>
On Wed, Nov 18, 2026 at 05:34:05AM -0500, Kimberly Morris wrote:
> A PHY driver can install a devm-backed mii_timestamper and select it as
> the default before its probe sequence has completed. If a later probe
> step fails, the driver core releases the driver's devres, but the
> phy_device retains both timestamping fields.
>
> If the generic PHY driver later attaches, skb_defer_rx_timestamp() can
> dereference the freed mii_timestamper. This also affects non-PTP packets
> because the receive path tests hwtstamp_set before classifying the
> packet.
This is very theoretical. It means root has unloaded the device
specific driver leaving just genphy. Very unlikely.
> Fixes: 39db6be781cd ("net: phy: broadcom: Add PTP support for some
> Broadcom PHYs.")
> Cc: stable@vger.kernel.org
Since this never happens, it bothers nobody, net-next.
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -3812,8 +3812,10 @@ EXPORT_SYMBOL_GPL(fwnode_get_phy_node);
> static int phy_probe(struct device *dev)
> {
> struct phy_device *phydev = to_phy_device(dev);
> + struct mii_timestamper *mii_ts = phydev->mii_ts;
> struct device_driver *drv = phydev->mdio.dev.driver;
> struct phy_driver *phydrv = to_phy_driver(drv);
> + bool default_timestamp = phydev->default_timestamp;
> int err = 0;
>
> phydev->drv = phydrv;
> @@ -3951,6 +3953,9 @@ static int phy_probe(struct device *dev)
> phydev->drv->remove(phydev);
>
> out_reset:
> + phydev->mii_ts = mii_ts;
> + phydev->default_timestamp = default_timestamp;
> +
The basic fix is wrong. If probe fails, everything done so far should
be undone. When probe is entered, there is no stamper. If probe exists
with an error, there should be no stamper.
Andrew
next prev parent reply other threads:[~2026-11-19 13:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 10:33 [PATCH net 0/2] net: phy: fix timestamping lifetime after " Kimberly Morris
2026-11-18 10:34 ` [PATCH net 1/2] net: phy: restore timestamping state on " Kimberly Morris
2026-11-18 14:05 ` Andrew Lunn
2026-11-19 13:23 ` Andrew Lunn [this message]
2026-11-18 10:34 ` [PATCH net 2/2] net: phy: broadcom: release PTP clock with PHY devres Kimberly Morris
2026-11-18 14:08 ` Andrew Lunn
2026-11-19 13:27 ` Andrew Lunn
2026-11-18 10:38 ` [PATCH net 0/2] net: phy: fix timestamping lifetime after probe failure netdev-bot+sinfo
2026-11-18 10:57 ` Kimberly Morris
2026-11-19 13:28 ` Andrew Lunn
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=c1075f39-c0b2-44cd-9338-b3506419f685@lunn.ch \
--to=andrew@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=gy770616@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=w@1wt.eu \
/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®