[PATCH net] ptp: fc3: unregister PTP clock on probe failure

From: Myeonghun Pak

Date: Tue Jul 28 2026 - 22:21:34 EST


ptp_clock_register() leaves a registered clock referring to the clock
information embedded in idtfc3. If either post-registration operation
fails, probe returns and devres frees idtfc3 without unregistering the
clock.

Unregister the clock on both post-registration failure paths.

Fixes: 1ddfecafabf7 ("ptp: add FemtoClock3 Wireless as ptp hardware clock")
Cc: stable@xxxxxxxxxxxxxxx
Co-developed-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Myeonghun Pak <mhun512@xxxxxxxxx>
---
drivers/ptp/ptp_fc3.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/ptp/ptp_fc3.c b/drivers/ptp/ptp_fc3.c
--- a/drivers/ptp/ptp_fc3.c
+++ b/drivers/ptp/ptp_fc3.c
@@ -835,11 +835,11 @@ static int idtfc3_enable_ptp(struct idtfc3 *idtfc3)

err = idtfc3_set_overhead(idtfc3);
if (err)
- return err;
+ goto err_unregister_clock;

err = idtfc3_init_timecounter(idtfc3);
if (err)
- return err;
+ goto err_unregister_clock;

dev_info(idtfc3->dev, "TIME_SYNC_CHANNEL registered as ptp%d",
idtfc3->ptp_clock->index);
@@ -847,4 +847,8 @@ static int idtfc3_enable_ptp(struct idtfc3 *idtfc3)
return 0;
+
+err_unregister_clock:
+ ptp_clock_unregister(idtfc3->ptp_clock);
+ return err;
}

static int idtfc3_load_firmware(struct idtfc3 *idtfc3)
--
2.50.1