All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tzung-Bi Shih" <tzungbi@kernel.org>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v2 8/9] watchdog: msc313e: Propagate error code in resume()
Date: Fri, 28 Aug 2026 16:27:03 +0000	[thread overview]
Message-ID: <20260828162703.9F9DF1F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260828161348.13212-9-tzungbi@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The driver manually clears core-managed watchdog flags (WDOG_HW_RUNNING and WDOG_ACTIVE) upon resume failure, which violates subsystem boundaries and causes userspace watchdog pings to silently succeed while the hardware watchdog is actually stopped.
--

commit 671369d67bb1efa18f6207e680185bff41e40d0e
Author: Tzung-Bi Shih <tzungbi@kernel.org>

watchdog: msc313e: Propagate error code in resume()

If msc313e_wdt_start() fails during system resume, the error is
currently ignored. Consequently, the watchdog isn't running without the
user's knowledge. This commit propagates the error code, prints a
message, and explicitly clears both the WDOG_HW_RUNNING and WDOG_ACTIVE
flags if start fails.

> diff --git a/drivers/watchdog/msc313e_wdt.c b/drivers/watchdog/msc313e_wdt.c
> index eea26c6c95d84..eff90ddeb3634 100644
> --- a/drivers/watchdog/msc313e_wdt.c
> +++ b/drivers/watchdog/msc313e_wdt.c
> @@ -192,11 +192,19 @@ static int __maybe_unused msc313e_wdt_suspend(struct device *dev)
>  static int __maybe_unused msc313e_wdt_resume(struct device *dev)
>  {
>  	struct msc313e_wdt_priv *priv = dev_get_drvdata(dev);
> +	int ret = 0;
>  
> -	if (watchdog_active(&priv->wdev) || watchdog_hw_running(&priv->wdev))
> -		msc313e_wdt_start(&priv->wdev);
> +	if (watchdog_active(&priv->wdev) || watchdog_hw_running(&priv->wdev)) {
> +		ret = msc313e_wdt_start(&priv->wdev);
> +		if (ret) {
> +			dev_err(dev, "Failed to restart watchdog (err=%d)\n", ret);
>  
> -	return 0;
> +			clear_bit(WDOG_HW_RUNNING, &priv->wdev.status);
> +			clear_bit(WDOG_ACTIVE, &priv->wdev.status);

[Severity: High]
Does manually clearing these core-managed flags cause userspace watchdog
pings to silently succeed while the hardware watchdog is actually stopped?

If msc313e_wdt_start() fails during system resume in msc313e_wdt_resume(),
the driver manually clears the WDOG_HW_RUNNING and WDOG_ACTIVE flags.

Later, when the userspace daemon writes to /dev/watchdog, the core
watchdog_ping() function could immediately return 0 (success) because
watchdog_hw_running() evaluates to false. This bypasses the driver's .ping
callback and returns success to userspace, hiding the dead state from
monitoring software.

> +		}
> +	}
> +
> +	return ret;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260828161348.13212-1-tzungbi@kernel.org?part=8

  reply	other threads:[~2026-08-28 16:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28 16:13 [PATCH v2 0/9] watchdog: msc313e: Fix issues Sashiko reported Tzung-Bi Shih
2026-08-28 16:13 ` [PATCH v2 1/9] watchdog: msc313e: Fix NULL pointer dereference in PM callbacks Tzung-Bi Shih
2026-09-09 21:07   ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 2/9] watchdog: msc313e: Avoid division by zero Tzung-Bi Shih
2026-09-09 21:08   ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 3/9] watchdog: msc313e: Fix clock leak and spurious timer in settimeout() Tzung-Bi Shih
2026-09-09 21:10   ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 4/9] watchdog: msc313e: Enable clock before accessing hardware registers Tzung-Bi Shih
2026-08-28 16:25   ` sashiko-bot
2026-09-09 21:14   ` Guenter Roeck
2026-09-12 16:36     ` Tzung-Bi Shih
2026-08-28 16:13 ` [PATCH v2 5/9] watchdog: msc313e: Fix spurious reset on suspend Tzung-Bi Shih
2026-08-28 16:25   ` sashiko-bot
2026-09-09 21:16   ` Guenter Roeck
2026-09-09 23:02     ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 6/9] watchdog: msc313e: Fix undefined behavior Tzung-Bi Shih
2026-09-09 21:17   ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 7/9] watchdog: msc313e: Sync timeout value if WDT was running at boot Tzung-Bi Shih
2026-08-28 16:22   ` sashiko-bot
2026-09-09 21:19   ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 8/9] watchdog: msc313e: Propagate error code in resume() Tzung-Bi Shih
2026-08-28 16:27   ` sashiko-bot [this message]
2026-09-09 21:21   ` Guenter Roeck
2026-08-28 16:13 ` [PATCH v2 9/9] watchdog: msc313e: Replace commas with semicolons in probe() Tzung-Bi Shih
2026-09-09 21:22   ` Guenter Roeck
2026-08-28 16:20 ` [PATCH v2 0/9] watchdog: msc313e: Fix issues Sashiko reported Daniel Palmer

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=20260828162703.9F9DF1F00A3E@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tzungbi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.