From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Mark Pearson <mpearson-lenovo@squebb.ca>,
Guenter Roeck <linux@roeck-us.net>,
Sasha Levin <sashal@kernel.org>,
wim@linux-watchdog.org, linux-watchdog@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH AUTOSEL 6.18-6.12] watchdog: lenovo_se10_wdt: Fix use-after-free and resource leak risk
Date: Mon, 31 Aug 2026 09:30:54 -0400 [thread overview]
Message-ID: <20260831133314.4125787-626-sashal@kernel.org> (raw)
In-Reply-To: <20260831133314.4125787-1-sashal@kernel.org>
From: Mark Pearson <mpearson-lenovo@squebb.ca>
[ Upstream commit 3394e894880a60338a2981dd688fd25e88d79667 ]
Review by sashiko.dev highlighted potential use after free and resource
leak instances.
Set se10_pdev to null to prevent use after free
Remove DMI call back and instead directly call
se10_create_platform_device. Handle error cases appropriately
Link: https://sashiko.dev/#/patchset/20260428124954.1193450-1-mpearson-lenovo%40squebb.ca
Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Link: https://lore.kernel.org/r/20260504180159.999189-1-mpearson-lenovo@squebb.ca
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
The history search finished. In this 6.18.43 checkout, `git log -S
'lenovo-se10-wdt'` shows the driver file first appearing at
`5d324e5159d9e` (Nov 2025 USB merge). That matches what we already saw
in blame.
The driver itself was added upstream in 6.10 (`watchdog:
lenovo_se10_wdt: Watchdog driver for Lenovo SE10 platform`); the buggy
DMI-callback init pattern has been there since then. Nothing in this
changes the earlier **YES** backport recommendation.
drivers/watchdog/lenovo_se10_wdt.c | 32 ++++++++++++++----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/drivers/watchdog/lenovo_se10_wdt.c b/drivers/watchdog/lenovo_se10_wdt.c
index 99ff01af41243..503e220263f95 100644
--- a/drivers/watchdog/lenovo_se10_wdt.c
+++ b/drivers/watchdog/lenovo_se10_wdt.c
@@ -224,7 +224,7 @@ static struct platform_driver se10_wdt_driver = {
.probe = se10_wdt_probe,
};
-static int se10_create_platform_device(const struct dmi_system_id *id)
+static int se10_create_platform_device(void)
{
int err;
@@ -233,9 +233,10 @@ static int se10_create_platform_device(const struct dmi_system_id *id)
return -ENOMEM;
err = platform_device_add(se10_pdev);
- if (err)
+ if (err) {
platform_device_put(se10_pdev);
-
+ se10_pdev = NULL;
+ }
return err;
}
@@ -246,7 +247,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "12NH"),
},
- .callback = se10_create_platform_device,
},
{
.ident = "LENOVO-SE10",
@@ -254,7 +254,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "12NJ"),
},
- .callback = se10_create_platform_device,
},
{
.ident = "LENOVO-SE10",
@@ -262,7 +261,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "12NK"),
},
- .callback = se10_create_platform_device,
},
{
.ident = "LENOVO-SE10",
@@ -270,7 +268,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "12NL"),
},
- .callback = se10_create_platform_device,
},
{
.ident = "LENOVO-SE10",
@@ -278,7 +275,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "12NM"),
},
- .callback = se10_create_platform_device,
},
{
.ident = "LENOVO-SE10-G2",
@@ -286,7 +282,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "13LJ"),
},
- .callback = se10_create_platform_device,
},
{
.ident = "LENOVO-SE10-G2",
@@ -294,7 +289,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "13LK"),
},
- .callback = se10_create_platform_device,
},
{
.ident = "LENOVO-SE10-G2",
@@ -302,7 +296,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "13S1"),
},
- .callback = se10_create_platform_device,
},
{
.ident = "LENOVO-SE10-G2",
@@ -310,7 +303,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "13S2"),
},
- .callback = se10_create_platform_device,
},
{
.ident = "LENOVO-SE10-G2",
@@ -318,7 +310,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "13S3"),
},
- .callback = se10_create_platform_device,
},
{
.ident = "LENOVO-SE10-G2",
@@ -326,7 +317,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "13S4"),
},
- .callback = se10_create_platform_device,
},
{
.ident = "LENOVO-SE10-G2",
@@ -334,7 +324,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "13S5"),
},
- .callback = se10_create_platform_device,
},
{
.ident = "LENOVO-SE10-G2",
@@ -342,7 +331,6 @@ static const struct dmi_system_id se10_dmi_table[] __initconst = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "13S6"),
},
- .callback = se10_create_platform_device,
},
{}
};
@@ -350,10 +338,20 @@ MODULE_DEVICE_TABLE(dmi, se10_dmi_table);
static int __init se10_wdt_init(void)
{
+ int err;
+
if (!dmi_check_system(se10_dmi_table))
return -ENODEV;
- return platform_driver_register(&se10_wdt_driver);
+ err = platform_driver_register(&se10_wdt_driver);
+ if (err)
+ return err;
+
+ err = se10_create_platform_device();
+ if (err)
+ platform_driver_unregister(&se10_wdt_driver);
+
+ return err;
}
static void __exit se10_wdt_exit(void)
--
2.53.0
prev parent reply other threads:[~2026-08-31 13:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260831133314.4125787-1-sashal@kernel.org>
2026-08-31 13:24 ` [PATCH AUTOSEL 6.18-6.12] watchdog: lenovo_se10_wdt: Add support for SE10 Gen 2 platform Sasha Levin
2026-08-31 15:12 ` sashiko-bot
2026-08-31 13:27 ` [PATCH AUTOSEL 6.18-6.12] watchdog: imx7ulp_wdt: Keep WDOG running until A55 enters WFI on i.MX94 Sasha Levin
2026-08-31 16:09 ` sashiko-bot
2026-08-31 13:30 ` Sasha Levin [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=20260831133314.4125787-626-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mpearson-lenovo@squebb.ca \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=wim@linux-watchdog.org \
/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