public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Junjie Cao <junjie.cao@intel.com>
Cc: Miri Korenblit <miriam.rachel.korenblit@intel.com>,
	Johannes Berg <johannes.berg@intel.com>,
	linux-wireless@vger.kernel.org,
	Richard Cochran <richardcochran@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yedidya Benshimol <yedidya.ben.shimol@intel.com>,
	Avraham Stern <avraham.stern@intel.com>,
	Daniel Gabay <daniel.gabay@intel.com>,
	Krishnanand Prabhu <krishnanand.prabhu@intel.com>,
	Luca Coelho <luciano.coelho@intel.com>,
	Gregory Greenman <gregory.greenman@intel.com>,
	stable@vger.kernel.org, Yao Zi <ziyao@disroot.org>,
	Benjamin Berg <benjamin.berg@intel.com>
Subject: Re: [PATCH] wifi: iwlwifi: ptp: Fix potential race condition in PTP removal
Date: Mon, 19 Jan 2026 17:29:06 +0000	[thread overview]
Message-ID: <aW5p4jVhcz70ZFl4@horms.kernel.org> (raw)
In-Reply-To: <20260115161529.85720-1-junjie.cao@intel.com>

+ Yao Zi and Benjamin Berg

On Fri, Jan 16, 2026 at 12:15:29AM +0800, Junjie Cao wrote:
> iwl_mvm_ptp_remove() and iwl_mld_ptp_remove() call
> cancel_delayed_work_sync() only after ptp_clock_unregister() and after
> partially clearing ptp_data state.
> 
> This creates a race where the delayed work (iwl_mvm_ptp_work /
> iwl_mld_ptp_work) can run while teardown is in progress and observe a
> partially modified PTP state. In addition, the work may re-arm itself,
> extending the teardown window and risking execution after driver
> resources have been released.
> 
> Move cancel_delayed_work_sync() before ptp_clock_unregister() to ensure
> the delayed work is fully stopped before any PTP cleanup begins. This
> follows the standard pattern used by other Intel PTP drivers such as
> e1000e, igb, ixgbe, and ice.
> 
> Fixes: d1e879ec600f ("wifi: iwlwifi: add iwlmld sub-driver")
> Fixes: 1595ecce1cf3 ("wifi: iwlwifi: mvm: add support for PTP HW clock (PHC)")
> Cc: stable@vger.kernel.org
> Signed-off-by: Junjie Cao <junjie.cao@intel.com>

Thinking out loud: The two cited commits were introduced in
the same upstream release - v6.4 - so from a backporting PoV
it seems reasonable to address these issues in one patch.
Though I do think it would be best to think of these
as two things and thus warranting two patches.

That notwithstanding, the changes look good to me.

Reviewed-by: Simon Horman <horms@kernel.org>

Context left intact below for the benefit of Yao Zi and Benjamin Berg.

> ---
>  drivers/net/wireless/intel/iwlwifi/mld/ptp.c | 2 +-
>  drivers/net/wireless/intel/iwlwifi/mvm/ptp.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/intel/iwlwifi/mld/ptp.c b/drivers/net/wireless/intel/iwlwifi/mld/ptp.c
> index 231920425c06..b40182320801 100644
> --- a/drivers/net/wireless/intel/iwlwifi/mld/ptp.c
> +++ b/drivers/net/wireless/intel/iwlwifi/mld/ptp.c
> @@ -319,10 +319,10 @@ void iwl_mld_ptp_remove(struct iwl_mld *mld)
>  			       mld->ptp_data.ptp_clock_info.name,
>  			       ptp_clock_index(mld->ptp_data.ptp_clock));
>  
> +		cancel_delayed_work_sync(&mld->ptp_data.dwork);
>  		ptp_clock_unregister(mld->ptp_data.ptp_clock);
>  		mld->ptp_data.ptp_clock = NULL;
>  		mld->ptp_data.last_gp2 = 0;
>  		mld->ptp_data.wrap_counter = 0;
> -		cancel_delayed_work_sync(&mld->ptp_data.dwork);
>  	}
>  }
> diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ptp.c b/drivers/net/wireless/intel/iwlwifi/mvm/ptp.c
> index 1da6260e238c..2b01ca36a1b5 100644
> --- a/drivers/net/wireless/intel/iwlwifi/mvm/ptp.c
> +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ptp.c
> @@ -325,11 +325,11 @@ void iwl_mvm_ptp_remove(struct iwl_mvm *mvm)
>  			       mvm->ptp_data.ptp_clock_info.name,
>  			       ptp_clock_index(mvm->ptp_data.ptp_clock));
>  
> +		cancel_delayed_work_sync(&mvm->ptp_data.dwork);
>  		ptp_clock_unregister(mvm->ptp_data.ptp_clock);
>  		mvm->ptp_data.ptp_clock = NULL;
>  		memset(&mvm->ptp_data.ptp_clock_info, 0,
>  		       sizeof(mvm->ptp_data.ptp_clock_info));
>  		mvm->ptp_data.last_gp2 = 0;
> -		cancel_delayed_work_sync(&mvm->ptp_data.dwork);
>  	}
>  }
> -- 
> 2.43.0
> 

  reply	other threads:[~2026-01-19 17:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-15 16:15 [PATCH] wifi: iwlwifi: ptp: Fix potential race condition in PTP removal Junjie Cao
2026-01-19 17:29 ` Simon Horman [this message]
2026-01-19 21:32 ` Vadim Fedorenko
2026-02-09  8:32 ` Korenblit, Miriam Rachel
2026-02-12 10:24   ` Junjie Cao
2026-02-12 12:50   ` [PATCH v2 1/2] wifi: iwlwifi: mvm: fix " Junjie Cao
2026-02-12 12:50     ` [PATCH v2 2/2] wifi: iwlwifi: mld: " Junjie Cao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aW5p4jVhcz70ZFl4@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=avraham.stern@intel.com \
    --cc=benjamin.berg@intel.com \
    --cc=daniel.gabay@intel.com \
    --cc=gregory.greenman@intel.com \
    --cc=johannes.berg@intel.com \
    --cc=junjie.cao@intel.com \
    --cc=krishnanand.prabhu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luciano.coelho@intel.com \
    --cc=miriam.rachel.korenblit@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=yedidya.ben.shimol@intel.com \
    --cc=ziyao@disroot.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox