[PATCH net 0/2] net: fec: fix PTP clock teardown races on device removal

From: Shengzhuo Wei

Date: Thu Sep 03 2026 - 16:32:07 EST


fec_drv_remove() calls fec_ptp_stop() before the netdev is unregistered
and freed, but PTP teardown leaves dangling references behind. The PHC
pointer remains set after ptp_clock_unregister(), so an ethtool -T on the
still-registered netdev can pass it to ptp_clock_index() after the clock
structure has been freed.

An in-flight PPS handler can race ptp_clock_unregister(). The devm-managed
handler also remains registered past free_netdev() and can dereference the
freed netdev before device-managed resources are released.

This series closes both holes at their respective introduction points.
Look up the PHC index by the parent device and clear fep->ptp_clock after
unregistering the PHC, then explicitly free the dedicated PPS interrupt
before the PHC and netdev teardown.

Found by source inspection while reviewing PTP teardown paths. Verified by
compiling the driver with W=1. No hardware was available to reproduce the
races.

---
Shengzhuo Wei (2):
net: fec: don't leave a stale PTP clock pointer after unregister
net: fec: free the PPS interrupt before tearing down the PHC and netdev

drivers/net/ethernet/freescale/fec.h | 1 +
drivers/net/ethernet/freescale/fec_main.c | 3 +--
drivers/net/ethernet/freescale/fec_ptp.c | 15 +++++++++++++--
3 files changed, 15 insertions(+), 4 deletions(-)
---
base-commit: 548e7bcd0c5460ddcbca9600cea603ebeebf4da7
change-id: 20260901-fec-ptp-pps-event-uaf-dcc71b5e1db0

Best regards,
--
Shengzhuo Wei <me@xxxxxxxx>