From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCHv2 2/3] watchdog: sama5d4: use platform_get_irq_optional()
Date: Mon, 08 Jun 2026 20:16:08 +0000 [thread overview]
Message-ID: <20260608201608.AAE3E1F00899@smtp.kernel.org> (raw)
In-Reply-To: <20260608200933.18669-3-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The interrupt handler relies on platform drvdata but is registered before drvdata is set, which can lead to a NULL pointer dereference.
--
commit 6a0bceec2bdd17bb8ca5d9b9518a193041169703
Author: Rosen Penev <rosenp@gmail.com>
watchdog: sama5d4: use platform_get_irq_optional()
This commit replaces irq_of_parse_and_map() with platform_get_irq_optional()
to avoid needing irq_dispose_mapping() on failure. It also adds handling for
-EPROBE_DEFER.
> diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
> index 13e72918338a2..e12499547d735 100644
> --- a/drivers/watchdog/sama5d4_wdt.c
> +++ b/drivers/watchdog/sama5d4_wdt.c
[ ... ]
> @@ -286,8 +285,11 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
> return ret;
>
> if (wdt->need_irq) {
> - irq = irq_of_parse_and_map(dev->of_node, 0);
> - if (!irq) {
> + irq = platform_get_irq_optional(pdev, 0);
> + if (irq == -EPROBE_DEFER)
> + return irq;
> +
> + if (irq < 0) {
> dev_warn(dev, "failed to get IRQ from DT\n");
> wdt->need_irq = false;
> }
[Severity: High]
This is a pre-existing issue, but since the interrupt is registered
with IRQF_SHARED shortly after this, could the handler fire before
platform_set_drvdata() is called?
In sama5d4_wdt_probe(), the interrupt is registered like this:
ret = devm_request_irq(dev, irq, sama5d4_wdt_irq_handler,
IRQF_SHARED | IRQF_IRQPOLL |
IRQF_NO_SUSPEND, pdev->name, pdev);
Because it is shared, another device on the same IRQ line could trigger
an interrupt immediately. The handler then retrieves the wdt pointer
using platform_get_drvdata():
drivers/watchdog/sama5d4_wdt.c:sama5d4_wdt_irq_handler() {
struct sama5d4_wdt *wdt = platform_get_drvdata(dev_id);
...
if (wdt->sam9x60_support)
...
}
However, platform_set_drvdata() is only called at the very end of
sama5d4_wdt_probe(). Would this result in a NULL pointer dereference
if the interrupt triggers early? Should platform_set_drvdata() be
moved before the interrupt is requested?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260608200933.18669-3-rosenp@gmail.com?part=1
next prev parent reply other threads:[~2026-06-08 20:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 20:09 [PATCHv2 0/3] watchdog: sama5d4: fix IRQ and timeout bugs, use platform_get_irq_optional Rosen Penev
2026-06-08 20:09 ` [PATCHv2 1/3] watchdog: sama5d4: fix shared IRQ and hardcoded timeout issues Rosen Penev
2026-06-08 20:22 ` sashiko-bot
2026-06-08 22:35 ` Guenter Roeck
2026-06-08 20:09 ` [PATCHv2 2/3] watchdog: sama5d4: use platform_get_irq_optional() Rosen Penev
2026-06-08 20:16 ` sashiko-bot [this message]
2026-06-08 22:44 ` Guenter Roeck
2026-06-08 20:09 ` [PATCHv2 3/3] watchdog: sama5d4: fix NULL deref in irq handler Rosen Penev
2026-06-08 20:20 ` sashiko-bot
2026-06-08 20:38 ` [PATCHv2 0/3] watchdog: sama5d4: fix IRQ and timeout bugs, use platform_get_irq_optional Nicolas Ferre
2026-06-08 20:42 ` 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=20260608201608.AAE3E1F00899@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