From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Runyu Xiao <runyu.xiao@seu.edu.cn>,
Richard Cochran <richardcochran@gmail.com>,
Jonathan Lemon <jonathan.lemon@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Jianhao Xu <jianhao.xu@seu.edu.cn>
Subject: Re: [PATCH net] ptp: ocp: prevent watchdog rearming during detach
Date: Fri, 4 Sep 2026 11:08:24 +0100 [thread overview]
Message-ID: <783cc6a6-78ff-4bbd-ae64-7cadfdead560@linux.dev> (raw)
In-Reply-To: <20260904064308.4044677-1-runyu.xiao@seu.edu.cn>
On 04/09/2026 07:43, Runyu Xiao wrote:
> ptp_ocp_detach() uses timer_delete_sync() to stop the watchdog before
> freeing the ptp_ocp state. timer_delete_sync() waits for a callback that is
> already running but does not prevent the callback from rearming the timer.
>
> Since ptp_ocp_watchdog() unconditionally calls mod_timer(), detach can
> return with the watchdog pending. A later callback can access freed state.
>
> Use timer_shutdown_sync() for the final watchdog teardown. This ensures the
> callback is complete and cannot rearm the timer before the state is freed.
>
> Fixes: 773bda964921 ("ptp: ocp: Expose various resources on the timecard.")
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:GPT-5
> Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
> ---
> drivers/ptp/ptp_ocp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 3d26ec1f7..6b5f615a2 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -4870,7 +4870,7 @@ ptp_ocp_detach(struct ptp_ocp *bp)
> ptp_ocp_debugfs_remove_device(bp);
> ptp_ocp_detach_sysfs(bp);
> ptp_ocp_attr_group_del(bp);
> - timer_delete_sync(&bp->watchdog);
> + timer_shutdown_sync(&bp->watchdog);
> /* Disable interrupts on all timestampers */
> if (bp->ts0)
> ptp_ocp_ts_enable(bp->ts0, 0, false);
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
prev parent reply other threads:[~2026-09-04 10:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 6:43 [PATCH net] ptp: ocp: prevent watchdog rearming during detach Runyu Xiao
2026-09-04 10:08 ` Vadim Fedorenko [this message]
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=783cc6a6-78ff-4bbd-ae64-7cadfdead560@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=jianhao.xu@seu.edu.cn \
--cc=jonathan.lemon@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=runyu.xiao@seu.edu.cn \
--cc=stable@vger.kernel.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