All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Antonio Borneo" <antonio.borneo@foss.st.com>,
	devicetree@vger.kernel.org
Cc: linux-watchdog@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 03/13] watchdog: stm32_iwdg: add pretimeout support for iwdg v4.0
Date: Fri, 06 Nov 2026 17:11:28 +0000	[thread overview]
Message-ID: <sashiko-outbox-201901@kernel.org> (raw)
In-Reply-To: <20261106163429.618392-4-antonio.borneo@foss.st.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] watchdog: stm32_iwdg: IRQ enabled before state init in
  stm32_iwdg_probe()
--

commit f781715ad1087a5b9a86d2dd54ce3b998243a348
Author: Antonio Borneo <antonio.borneo@foss.st.com>

watchdog: stm32_iwdg: add pretimeout support for iwdg v4.0

This commit updates stm32_iwdg_isr() to clear pretimeout interrupts via
IWDG_ICR on IWDG hardware version 4.0 and later, and adds a reg_set()
helper.

> diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c
> index ce3e1f96ef50a..6121c23889655 100644
> --- a/drivers/watchdog/stm32_iwdg.c
> +++ b/drivers/watchdog/stm32_iwdg.c
[ ... ]
> @@ -194,11 +207,11 @@ static irqreturn_t stm32_iwdg_isr(int irq, void *wdog_arg)
>  {
>  	struct watchdog_device *wdd = wdog_arg;
>  	struct stm32_iwdg *wdt = watchdog_get_drvdata(wdd);
> -	u32 reg;
>  
> -	reg = reg_read(wdt->regs, IWDG_EWCR);
> -	reg |= EWCR_EWIC;
> -	reg_write(wdt->regs, IWDG_EWCR, reg);
> +	if (wdt->hw_version >= ICR_MIN_VER)
> +		reg_write(wdt->regs, IWDG_ICR, ICR_EWIC);
> +	else
> +		reg_set(wdt->regs, IWDG_EWCR, EWCR_EWIC);
>  
>  	watchdog_notify_pretimeout(wdd);

[Severity: Medium]
Can stm32_iwdg_isr() run before wdt->hw_version and wdd's driver data are
initialized in stm32_iwdg_probe()?

drivers/watchdog/stm32_iwdg.c:stm32_iwdg_probe() {
    ...
	ret = stm32_iwdg_irq_init(pdev, wdt);
	if (ret)
		return ret;

	wdt->hw_version = reg_read(wdt->regs, IWDG_VERR) & VERR_MASK;

	watchdog_set_drvdata(wdd, wdt);
    ...
}

stm32_iwdg_irq_init() calls devm_request_irq() before wdt->hw_version is
read from IWDG_VERR and before watchdog_set_drvdata() sets wdd's driver
data.  If the watchdog was already started by the bootloader and a
pretimeout interrupt is pending when the IRQ is requested, stm32_iwdg_isr()
gets NULL from watchdog_get_drvdata(wdd) and dereferences a NULL pointer,
and even with driver data set, wdt->hw_version would still be 0 so v4.0+
hardware would write to IWDG_EWCR instead of IWDG_ICR and fail to clear
the interrupt.

Initializing wdt->hw_version and calling watchdog_set_drvdata(wdd, wdt)
before stm32_iwdg_irq_init() would avoid this window.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261106163429.618392-1-antonio.borneo@foss.st.com?part=3

  reply	other threads:[~2026-11-06 17:11 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 16:34 [PATCH v3 00/13] Update watchdogs support on STM32MP platforms Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 01/13] watchdog: stm32_iwdg: get hardware version during probe Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 02/13] watchdog: stm32_iwdg: detect whether the watchdog is running Antonio Borneo
2026-11-06 17:05   ` sashiko-bot
2026-11-08 17:56     ` Guenter Roeck
2026-11-09 11:27       ` Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 03/13] watchdog: stm32_iwdg: add pretimeout support for iwdg v4.0 Antonio Borneo
2026-11-06 17:11   ` sashiko-bot [this message]
2026-11-06 16:34 ` [PATCH v3 04/13] ARM: stm32: enable arm smc watchdog on stm32mp1xx Antonio Borneo
2026-11-06 17:19   ` sashiko-bot
2026-11-06 22:18     ` Guenter Roeck
2026-11-09 10:32       ` Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 05/13] ARM: dts: stm32: add iwdg1 node on stm32mp151 SoC Antonio Borneo
2026-11-06 17:29   ` sashiko-bot
2026-11-06 16:34 ` [PATCH v3 06/13] ARM: dts: stm32: enable iwdg1 on stm32mp15x ST boards Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 07/13] ARM: dts: stm32: move arm smc watchdog to stm32mp151 SoC Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 08/13] ARM: dts: stm32: enable arm smc watchdog on stm32mp15x scmi boards Antonio Borneo
2026-11-06 17:51   ` sashiko-bot
2026-11-06 16:34 ` [PATCH v3 09/13] ARM: dts: stm32: add watchdog0 alias on ST stm32mp1xx boards Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 10/13] arm64: dts: st: add iwdg1 and iwdg2 support to stm32mp211 Antonio Borneo
2026-11-06 18:02   ` sashiko-bot
2026-11-06 16:34 ` [PATCH v3 11/13] arm64: dts: st: add iwdg1 and iwdg2 support to stm32mp231 Antonio Borneo
2026-11-06 18:13   ` sashiko-bot
2026-11-06 16:34 ` [PATCH v3 12/13] arm64: dts: st: add iwdg1 and iwdg2 support to stm32mp251 Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 13/13] arm64: dts: st: enable iwdg2 on stm32mp2xx ST boards Antonio Borneo
2026-11-06 18:24   ` sashiko-bot

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=sashiko-outbox-201901@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=antonio.borneo@foss.st.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=robh@kernel.org \
    --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 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.