All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH] watchdog: orion: Use of_device_get_match_data()
Date: Tue, 19 May 2026 00:52:32 +0000	[thread overview]
Message-ID: <20260519005232.DDE8EC2BCF7@smtp.kernel.org> (raw)
In-Reply-To: <20260519003742.626477-1-rosenp@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The clock is explicitly disabled before the `devm`-managed interrupt is freed, leading to a potential bus fault or system hang. This problem wasn't introduced by this patch, but it is a pre-existing high-severity bug.
--

commit d9eb7a064a32ff51e0077728d87320936861ffad
Author: Rosen Penev <rosenp@gmail.com>

watchdog: orion: Use of_device_get_match_data()

Use of_device_get_match_data() to fetch watchdog match data directly
instead of open-coding an of_match_device() lookup.

> diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c
> index 0e145f762f6f2..a92701ff26530 100644
> --- a/drivers/watchdog/orion_wdt.c
> +++ b/drivers/watchdog/orion_wdt.c
[ ... ]
> @@ -563,15 +561,14 @@ static int orion_wdt_probe(struct platform_device *pdev)
>  	if (!dev)
>  		return -ENOMEM;
>  
> -	match = of_match_device(orion_wdt_of_match_table, &pdev->dev);
> -	if (!match)
> +	dev->data = of_device_get_match_data(&pdev->dev);
> +	if (!dev->data)
>  		/* Default legacy match */
> -		match = &orion_wdt_of_match_table[0];
> +		dev->data = orion_wdt_of_match_table[0].data;
>  
>  	dev->wdt.info = &orion_wdt_info;
>  	dev->wdt.ops = &orion_wdt_ops;
>  	dev->wdt.min_timeout = 1;
> -	dev->data = match->data;
>  
>  	ret = orion_wdt_get_regs(pdev, dev);
>  	if (ret)

While reviewing this patch, I noticed a pre-existing issue in the probe
error path.

If watchdog_register_device() fails later in orion_wdt_probe(), the code
jumps to the disable_clk label:

        ret = watchdog_register_device(&dev->wdt);
        if (ret)
                goto disable_clk;

[ ... ]

disable_clk:
        clk_disable_unprepare(dev->clk);
        clk_put(dev->clk);
        return ret;

Since devm_request_irq() is used to allocate the interrupts, the devres
core will automatically free them only after the probe function returns.

Does this create a teardown window where the clock is explicitly disabled
but the interrupts remain active?

If a watchdog pre-timeout interrupt fires during this window, could the
handlers (orion_wdt_pre_irq or orion_wdt_irq) attempt to access
memory-mapped hardware registers while the clock is turned off, resulting
in a bus fault or system hang?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260519003742.626477-1-rosenp@gmail.com?part=1

      reply	other threads:[~2026-05-19  0:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19  0:37 [PATCH] watchdog: orion: Use of_device_get_match_data() Rosen Penev
2026-05-19  0:52 ` sashiko-bot [this message]

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=20260519005232.DDE8EC2BCF7@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 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.