iwl_mld_ptp_work() reads the GP2 register while holding data->lock. The lock only protects the software wraparound state, not the register read. gettime() and adjfine() already read GP2 first and only then take the lock; a read that races with a newer update is caught by iwl_mld_ptp_update_new_read() and dropped as an old read. Read the GP2 outside the lock. Assisted-by: LLM Reviewed-by: Emmanuel Grumbach Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/mld/ptp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mld/ptp.c b/drivers/net/wireless/intel/iwlwifi/mld/ptp.c index 9f7d17dbdee1..eafc261c15bb 100644 --- a/drivers/net/wireless/intel/iwlwifi/mld/ptp.c +++ b/drivers/net/wireless/intel/iwlwifi/mld/ptp.c @@ -173,11 +173,13 @@ static void iwl_mld_ptp_work(struct work_struct *wk) struct ptp_data *data = &mld->ptp_data; u32 gp2; - spin_lock_bh(&data->lock); - if (!iwl_mld_get_systime(mld, &gp2)) - iwl_mld_ptp_update_new_read(mld, gp2); - else + if (iwl_mld_get_systime(mld, &gp2)) { IWL_DEBUG_PTP(mld, "PTP work: failed to read GP2\n"); + return; + } + + spin_lock_bh(&data->lock); + iwl_mld_ptp_update_new_read(mld, gp2); spin_unlock_bh(&data->lock); } -- 2.34.1