From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v2 1/2] watchdog: pika_wdt: fix timer leak and close race
Date: Wed, 03 Jun 2026 04:10:49 +0000 [thread overview]
Message-ID: <20260603041050.54CFD1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260603040230.318998-2-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Moving `clear_bit()` before `timer_delete_sync()` in `pikawdt_release()` introduces a race condition with concurrent `open()` calls, leading to the deletion of a newly-armed timer and a spurious system reset.
- [Medium] Module teardown in `pikawdt_exit()` uses `timer_delete_sync()` instead of the mandatory `timer_shutdown_sync()` API.
--
commit a45c8a04ae522cdde52c3ffa747d60e630a011a9
Author: Rosen Penev <rosenp@gmail.com>
watchdog: pika_wdt: fix timer leak and close race
This commit fixes two timer lifecycle bugs in the PIKA watchdog driver. It
adds timer_delete_sync() in pikawdt_exit() to stop the ping timer before
unmapping the FPGA IO memory, and replaces timer_delete() with
timer_delete_sync() in pikawdt_release() while clearing the open bit
earlier to avoid a race.
> diff --git a/drivers/watchdog/pika_wdt.c b/drivers/watchdog/pika_wdt.c
> index 87b8988d25206..60a846cb36011 100644
> --- a/drivers/watchdog/pika_wdt.c
> +++ b/drivers/watchdog/pika_wdt.c
> @@ -127,11 +127,12 @@ static int pikawdt_open(struct inode *inode, struct file *file)
> */
> static int pikawdt_release(struct inode *inode, struct file *file)
> {
> + clear_bit(0, &pikawdt_private.open);
> +
> /* stop internal ping */
> if (!pikawdt_private.expect_close)
> - timer_delete(&pikawdt_private.timer);
> + timer_delete_sync(&pikawdt_private.timer);
[Severity: High]
Does moving clear_bit() before timer_delete_sync() in pikawdt_release()
introduce a race condition with concurrent open() calls?
If process A closes the device unexpectedly, it clears the open bit early.
Process B on another CPU could then successfully open the device and arm
the internal ping timer.
Process A would then resume and execute timer_delete_sync(), which deletes
the timer that process B just started.
Process B would believe it successfully acquired the watchdog, but the
internal ping timer is stopped, and the hardware watchdog could eventually
reset the system.
>
> - clear_bit(0, &pikawdt_private.open);
> pikawdt_private.expect_close = 0;
> return 0;
> }
> @@ -291,6 +292,7 @@ static void __exit pikawdt_exit(void)
> {
> misc_deregister(&pikawdt_miscdev);
>
> + timer_delete_sync(&pikawdt_private.timer);
[Severity: Medium]
Should pikawdt_exit() be using timer_shutdown_sync() instead?
Since this is the module teardown path right before unmapping the device
memory, timer_shutdown_sync() is strictly required to permanently prevent
the timer from being re-armed.
> iounmap(pikawdt_private.fpga);
> }
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260603040230.318998-1-rosenp@gmail.com?part=1
next prev parent reply other threads:[~2026-06-03 4:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 4:02 [PATCH v2 0/2] watchdog: pika_wdt: portability and timer lifecycle fixes Rosen Penev
2026-06-03 4:02 ` [PATCH v2 1/2] watchdog: pika_wdt: fix timer leak and close race Rosen Penev
2026-06-03 4:10 ` sashiko-bot [this message]
2026-06-03 4:02 ` [PATCH v2 2/2] watchdog: pika_wdt: replace in_be32/out_be32 with ioread32be/iowrite32be Rosen Penev
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=20260603041050.54CFD1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=rosenp@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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