Re: [PATCH v2 6/8] watchdog: w83627hf_wdt: Store Super I/O unlocking sequence in platform data

[email protected] Sun, 26 Jul 2026 18:55:04 +0000
Newsgroups org.kernel.vger.linux-watchdog
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 2 potential issue(=
s) to consider:
- [High] Missing NULL check for `platform_data` in `wdt_probe` leads to a k=
ernel panic.
- [High] Missing NULL check for `platform_get_device_id()` in `wdt_probe` l=
eads to a NULL pointer dereference.
--

--- Patch [6]: [PATCH v2 6/8] watchdog: w83627hf_wdt: Store Super I/O unloc=
king sequence in platform data ---
commit 60b05c387ecdfb14df4b8e624ec2e3f22d7a1aa6
Author: Paul Louvel <[email protected]>

watchdog: w83627hf_wdt: Store Super I/O unlocking sequence in platform data

This commit replaces the use of two global variables for the Super I/O=20
unlocking sequence. It instead stores the unlocking sequence in the=20
platform data.

> diff --git a/drivers/watchdog/w83627hf_wdt.c b/drivers/watchdog/w83627hf_=
wdt.c
> index a067b8ea6b289..064a99db80efe 100644
> --- a/drivers/watchdog/w83627hf_wdt.c
> +++ b/drivers/watchdog/w83627hf_wdt.c

[ ... ]

> @@ -439,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;
>  }
> =20
>  static int wdt_probe(struct platform_device *pdev)
>  {
>  	const struct platform_device_id *id =3D platform_get_device_id(pdev);
> +	const struct wdt_pdata *pdata =3D pdev->dev.platform_data;
>  	enum chips chip =3D id->driver_data;

[Severity: High]
Can platform_get_device_id() return NULL here if the driver is bound to a=20
device via sysfs driver_override or fallback name matching? If so, does=20
accessing id->driver_data cause a NULL pointer dereference?

>  	struct device *dev =3D &pdev->dev;
>  	struct watchdog_device *wdd;

[ ... ]

> @@ -476,6 +481,8 @@ static int wdt_probe(struct platform_device *pdev)
>  	wdd->max_timeout =3D 255;
> =20
>  	data->sioaddr =3D res->start;
> +	data->siocfg_enter =3D pdata->siocfg_enter;
> +	data->siocfg_leave =3D pdata->siocfg_leave;

[Severity: High]
What happens if the platform device is instantiated without platform data=20
and bound to this driver? Would pdev->dev.platform_data be NULL, leading=20
to a kernel panic when dereferencing pdata here?

>  	data->reg.timeout =3D W83627HF_WDT_TIMEOUT;
>  	data->reg.control =3D W83627HF_WDT_CONTROL;
>  	data->reg.csr =3D W836X7HF_WDT_CSR;

--=20
Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260726-w83627hf_w=
[email protected]?part=3D6