All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v2 2/2] watchdog: stm32_iwdg: Propagate errors from optional IRQ lookup
Date: Fri, 07 Aug 2026 08:17:01 +0000	[thread overview]
Message-ID: <20260807081701.C3D691F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260807080447.35479-2-phucduc.bui@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing cleanup of `dev_pm_set_wake_irq()` leads to a memory leak and causes subsequent probes to fail permanently with `-EEXIST`.
--

--- Patch [2]: [PATCH v2 2/2] watchdog: stm32_iwdg: Propagate errors from optional IRQ lookup ---
commit 2e08fbcd4cd54dae1e6ee4882052b35d6df14b51
Author: bui duc phuc <phucduc.bui@gmail.com>

watchdog: stm32_iwdg: Propagate errors from optional IRQ lookup

This commit updates the IRQ initialization in the stm32_iwdg watchdog
driver to properly propagate errors from platform_get_irq_optional(). It
ensures that errors such as -EPROBE_DEFER or -EINVAL are passed back to
the caller, rather than continuing the probe without an IRQ. The -ENXIO
return value is still treated as a missing optional IRQ and handled
gracefully.

Link v1: https://lore.kernel.org/all/20260806062812.26523-2-phucduc.bui@gmail.com/

> diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c
> index b356a272ff9a0..a8d2db2d3cf8b 100644
> --- a/drivers/watchdog/stm32_iwdg.c
> +++ b/drivers/watchdog/stm32_iwdg.c
> @@ -287,8 +287,11 @@ static int stm32_iwdg_irq_init(struct platform_device *pdev,
>  		return 0;
>  
>  	irq = platform_get_irq_optional(pdev, 0);
> -	if (irq <= 0)
> +	if (irq < 0) {
> +		if (irq != -ENXIO)
> +			return irq;
>  		return 0;
> +	}
>  
>  	if (of_property_read_bool(np, "wakeup-source")) {
>  		ret = devm_device_init_wakeup(dev);

[Severity: High]
This is a pre-existing issue, but since we are adjusting the error handling
around IRQs here, is there a missing cleanup path for the wake IRQ?

A bit further down in stm32_iwdg_irq_init(), the code calls the unmanaged
dev_pm_set_wake_irq(dev, irq) function:

	if (of_property_read_bool(np, "wakeup-source")) {
		...
		ret = dev_pm_set_wake_irq(dev, irq);
		if (ret)
			return ret;
	}

	ret = devm_request_irq(dev, irq, stm32_iwdg_isr, ...);

If devm_request_irq() fails immediately after, or if a subsequent setup step
like stm32_iwdg_start() fails in stm32_iwdg_probe(), the wake IRQ remains
attached because dev_pm_set_wake_irq() does not automatically clean up on
failure or device unbind.

Could this cause the memory for the wake IRQ to leak and leave a dangling
pointer in dev->power.wakeirq? If a probe deferral or unbind occurs,
would the next probe attempt fail permanently with -EEXIST when
dev_pm_set_wake_irq() encounters the dangling pointer? Would using
devm_pm_set_wake_irq() here instead ensure proper lifecycle management?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260807080447.35479-1-phucduc.bui@gmail.com?part=2

  reply	other threads:[~2026-08-07  8:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07  8:04 [PATCH v2 1/2] watchdog: orion_wdt: Propagate errors from optional IRQ lookup phucduc.bui
2026-08-07  8:04 ` [PATCH v2 2/2] watchdog: stm32_iwdg: " phucduc.bui
2026-08-07  8:17   ` sashiko-bot [this message]
2026-08-08  9:24     ` Bui Duc Phuc
2026-08-09 15:07   ` Guenter Roeck
2026-08-07  8:11 ` [PATCH v2 1/2] watchdog: orion_wdt: " sashiko-bot
2026-08-08  9:18   ` Bui Duc Phuc

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=20260807081701.C3D691F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=phucduc.bui@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 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.