mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 08:15:07 -04:00
ptp: fc3: register PTP clock after initialization
ptp_clock_register() exposes the clock to userspace. If either following initialization operation fails, probe returns and devres frees idtfc3 while the registered clock still refers to the clock information embedded in it. Complete the fallible initialization before registering the clock. Schedule the worker after registration because it requires the registered clock. This removes post-registration failures and avoids exposing a partially initialized clock. Cc: stable+noautosel@kernel.org # untested fix to a driver init path race Co-developed-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Myeonghun Pak <mhun512@gmail.com> Link: https://patch.msgid.link/20260803135942.48383-1-mhun512@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
f372283673
commit
762137ff74
@@ -665,8 +665,6 @@ static int idtfc3_init_timecounter(struct idtfc3 *idtfc3)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
ptp_schedule_worker(idtfc3->ptp_clock, idtfc3->tc_update_period);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -825,6 +823,14 @@ static int idtfc3_enable_ptp(struct idtfc3 *idtfc3)
|
||||
|
||||
idtfc3->caps = idtfc3_caps;
|
||||
snprintf(idtfc3->caps.name, sizeof(idtfc3->caps.name), "IDT FC3W");
|
||||
err = idtfc3_set_overhead(idtfc3);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = idtfc3_init_timecounter(idtfc3);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
idtfc3->ptp_clock = ptp_clock_register(&idtfc3->caps, NULL);
|
||||
|
||||
if (IS_ERR(idtfc3->ptp_clock)) {
|
||||
@@ -833,13 +839,7 @@ static int idtfc3_enable_ptp(struct idtfc3 *idtfc3)
|
||||
return err;
|
||||
}
|
||||
|
||||
err = idtfc3_set_overhead(idtfc3);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = idtfc3_init_timecounter(idtfc3);
|
||||
if (err)
|
||||
return err;
|
||||
ptp_schedule_worker(idtfc3->ptp_clock, idtfc3->tc_update_period);
|
||||
|
||||
dev_info(idtfc3->dev, "TIME_SYNC_CHANNEL registered as ptp%d",
|
||||
idtfc3->ptp_clock->index);
|
||||
|
||||
Reference in New Issue
Block a user