mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net: phy: microchip_rds_ptp: unregister the PTP clock if init fails
@ 2026-11-03 10:29 Wentao Liang
  2026-11-03 10:35 ` netdev-bot+sinfo
  2026-11-07 13:24 ` netdev-bot+sashiko
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-03 10:29 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel, Wentao Liang, stable

mchp_rds_ptp_probe() registers the PTP clock with ptp_clock_register()
and then initializes the hardware with mchp_rds_ptp_init(). The
initialization performs several MDIO writes and can fail, in which case
the function returns an error to the caller without unregistering the
clock that was just registered.

Nothing else releases that clock: the callers abort the PHY probe, and
the clock object allocated by ptp_clock_register(), together with its
character device and sysfs entries, stays around forever.

Unregister the clock on the error path, mirroring what the remove
callbacks of the other PTP capable PHY drivers do.

Fixes: fa51199c5f34 ("net: phy: microchip_rds_ptp : Add rds ptp library for Microchip phys")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/phy/microchip_rds_ptp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/microchip_rds_ptp.c b/drivers/net/phy/microchip_rds_ptp.c
index 2ad95d5c9d86..0db6eeb2660c 100644
--- a/drivers/net/phy/microchip_rds_ptp.c
+++ b/drivers/net/phy/microchip_rds_ptp.c
@@ -1318,8 +1318,10 @@ struct mchp_rds_ptp_clock *mchp_rds_ptp_probe(struct phy_device *phydev, u8 mmd,
 	clock->phydev = phydev;
 
 	rc = mchp_rds_ptp_init(clock);
-	if (rc < 0)
+	if (rc < 0) {
+		ptp_clock_unregister(clock->ptp_clock);
 		return ERR_PTR(rc);
+	}
 
 	return clock;
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-07 13:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 10:29 [PATCH] net: phy: microchip_rds_ptp: unregister the PTP clock if init fails Wentao Liang
2026-11-03 10:35 ` netdev-bot+sinfo
2026-11-07 13:24 ` netdev-bot+sashiko

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®