From: sashiko-bot@kernel.org
To: "Paul Louvel" <paul.louvel@bootlin.com>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH 6/9] watchdog: w83627hf_wdt: Store Super I/O unlocking sequence in platform data
Date: Sat, 25 Jul 2026 10:44:50 +0000 [thread overview]
Message-ID: <20260725104451.4AF7F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260725-w83627hf_wdt-improvements-v1-6-4e9a1b4e8297@bootlin.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The local stack variable `struct resource res` is partially uninitialized before being passed to `platform_device_register_resndata()`, leaking stack garbage and risking kernel panics.
- [High] Missing NULL check for `pdata` (`pdev->dev.platform_data`) in `wdt_probe` leads to an unconditional NULL pointer dereference.
- [High] Missing NULL check for `id` (`platform_get_device_id(pdev)`) in `wdt_probe` leads to a kernel panic.
--
--- Patch [6]: [PATCH 6/9] watchdog: w83627hf_wdt: Store Super I/O unlocking sequence in platform data ---
commit a8ddfa0e2fa7007bc7d8b51099f9722c0113c5c5
Author: Paul Louvel <paul.louvel@bootlin.com>
watchdog: w83627hf_wdt: Store Super I/O unlocking sequence in platform data
This patch stores the Super I/O unlocking sequence in the platform data
instead of using global variables.
> diff --git a/drivers/watchdog/w83627hf_wdt.c b/drivers/watchdog/w83627hf_wdt.c
> index 6363d571182fa..fed05fcf82bbf 100644
> --- a/drivers/watchdog/w83627hf_wdt.c
> +++ b/drivers/watchdog/w83627hf_wdt.c
[ ... ]
> @@ -441,13 +443,14 @@ static int wdt_find(int addr)
> pr_err("Unsupported chip ID: 0x%02x\n", val);
> break;
> }
> - superio_exit(addr);
> + superio_exit(addr, leave);
> return ret;
> }
>
> static int wdt_probe(struct platform_device *pdev)
> {
> const struct platform_device_id *id = platform_get_device_id(pdev);
> + const struct wdt_pdata *pdata = pdev->dev.platform_data;
> enum chips chip = id->driver_data;
[Severity: High]
Is it possible for id to be NULL here? If this driver is bound to an
arbitrary device via the driver_override sysfs interface (which skips setting
pdev->id_entry), platform_get_device_id(pdev) will return NULL. Will this
cause a kernel panic when dereferencing id->driver_data?
> struct watchdog_device *wdd;
> struct w83627hf_data *data;
[ ... ]
> @@ -477,6 +480,8 @@ static int wdt_probe(struct platform_device *pdev)
> wdd->max_timeout = 255;
>
> data->sioaddr = res->start;
> + data->siocfg_enter = pdata->siocfg_enter;
> + data->siocfg_leave = pdata->siocfg_leave;
[Severity: High]
Could pdata be NULL at this point? If a local privileged user manually
triggers driver binding via sysfs on a dummy platform device that lacks
platform_data, pdev->dev.platform_data will be NULL. Dereferencing pdata
here would result in a NULL pointer dereference.
> data->reg.timeout = W83627HF_WDT_TIMEOUT;
> data->reg.control = W83627HF_WDT_CONTROL;
> data->reg.csr = W836X7HF_WDT_CSR;
[ ... ]
> @@ -579,20 +589,22 @@ static struct platform_device *wdt_pdev;
>
> static int __init wdt_init(void)
> {
> - struct wdt_pdata pdata;
> struct resource res;
[Severity: High]
Does this code leave internal fields of the stack variable res uninitialized?
Since res is declared on the stack without being zero-initialized, fields
like parent, sibling, and child may contain stack garbage.
Later, when res is passed to platform_device_register_resndata(), it uses
kmemdup() to copy this struct. During platform_device_add(), the kernel
iterates over resources and checks if (!r->parent). Since res.parent
contains non-NULL stack garbage, it bypasses the default assignment and
passes the garbage pointer to insert_resource(), which could result in a
page fault and kernel panic during module load.
> int sioaddr;
> int ret;
> int chip;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260725-w83627hf_wdt-improvements-v1-0-4e9a1b4e8297@bootlin.com?part=6
next prev parent reply other threads:[~2026-07-25 10:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 10:29 [PATCH 0/9] watchdog: w83627hf_wdt: Convert driver to the driver model and add minute support Paul Louvel
2026-07-25 10:29 ` [PATCH 1/9] watchdog: w83627hf_wdt: Replace magic numbers with descriptive macros Paul Louvel
2026-07-25 14:44 ` Guenter Roeck
2026-07-25 10:29 ` [PATCH 2/9] watchdog: w83627hf_wdt: Convert to platform driver model Paul Louvel
2026-07-25 10:42 ` sashiko-bot
2026-07-25 14:48 ` Guenter Roeck
2026-07-25 10:29 ` [PATCH 3/9] watchdog: w83627hf_wdt: Use private driver data structure Paul Louvel
2026-07-25 10:42 ` sashiko-bot
2026-07-25 10:29 ` [PATCH 4/9] watchdog: w83627hf_wdt: Move register offsets into driver data Paul Louvel
2026-07-25 10:29 ` [PATCH 5/9] watchdog: w83627hf_wdt: Add Super I/O configuration port as a platform device resource Paul Louvel
2026-07-25 10:43 ` sashiko-bot
2026-07-25 10:29 ` [PATCH 6/9] watchdog: w83627hf_wdt: Store Super I/O unlocking sequence in platform data Paul Louvel
2026-07-25 10:44 ` sashiko-bot [this message]
2026-07-25 10:29 ` [PATCH 7/9] watchdog: w83627hf_wdt: Add minute mode counting Paul Louvel
2026-07-25 10:29 ` [PATCH 8/9] watchdog: w83627hf_wdt: Report all initialization failures in probe Paul Louvel
2026-07-25 10:36 ` sashiko-bot
2026-07-25 14:28 ` Guenter Roeck
2026-07-25 10:29 ` [PATCH 9/9] watchdog: w83627hf_wdt: Use dev_* logging instead of pr_* Paul Louvel
2026-07-25 14:30 ` Guenter Roeck
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=20260725104451.4AF7F1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=paul.louvel@bootlin.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.