* [PATCH v1] watchdog: lenovo_se30_wdt: Fix null-ptr-deref in lenovo_se30_wdt_probe()
@ 2025-04-24 7:16 Henry Martin
2025-04-24 12:10 ` Guenter Roeck
2025-04-25 7:20 ` Markus Elfring
0 siblings, 2 replies; 3+ messages in thread
From: Henry Martin @ 2025-04-24 7:16 UTC (permalink / raw)
To: wim, linux; +Cc: linux-watchdog, linux-kernel, Henry Martin
devm_ioremap() returns NULL on error. Currently, lenovo_se30_wdt_probe()
does not check for this case, which results in a NULL pointer
dereference.
Add NULL check after devm_ioremap() to prevent this issue.
Fixes: c284153a2c55 ("watchdog: lenovo_se30_wdt: Watchdog driver for Lenovo SE30 platform")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
drivers/watchdog/lenovo_se30_wdt.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/watchdog/lenovo_se30_wdt.c b/drivers/watchdog/lenovo_se30_wdt.c
index 024b842499b3..1c73bb7eeeee 100644
--- a/drivers/watchdog/lenovo_se30_wdt.c
+++ b/drivers/watchdog/lenovo_se30_wdt.c
@@ -271,6 +271,8 @@ static int lenovo_se30_wdt_probe(struct platform_device *pdev)
return -EBUSY;
priv->shm_base_addr = devm_ioremap(dev, base_phys, SHM_WIN_SIZE);
+ if (!priv->shm_base_addr)
+ return -ENOMEM;
priv->wdt_cfg.mod = WDT_MODULE;
priv->wdt_cfg.idx = WDT_CFG_INDEX;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] watchdog: lenovo_se30_wdt: Fix null-ptr-deref in lenovo_se30_wdt_probe()
2025-04-24 7:16 [PATCH v1] watchdog: lenovo_se30_wdt: Fix null-ptr-deref in lenovo_se30_wdt_probe() Henry Martin
@ 2025-04-24 12:10 ` Guenter Roeck
2025-04-25 7:20 ` Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2025-04-24 12:10 UTC (permalink / raw)
To: Henry Martin, wim; +Cc: linux-watchdog, linux-kernel
On 4/24/25 00:16, Henry Martin wrote:
> devm_ioremap() returns NULL on error. Currently, lenovo_se30_wdt_probe()
> does not check for this case, which results in a NULL pointer
> dereference.
>
> Add NULL check after devm_ioremap() to prevent this issue.
>
> Fixes: c284153a2c55 ("watchdog: lenovo_se30_wdt: Watchdog driver for Lenovo SE30 platform")
> Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/watchdog/lenovo_se30_wdt.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/watchdog/lenovo_se30_wdt.c b/drivers/watchdog/lenovo_se30_wdt.c
> index 024b842499b3..1c73bb7eeeee 100644
> --- a/drivers/watchdog/lenovo_se30_wdt.c
> +++ b/drivers/watchdog/lenovo_se30_wdt.c
> @@ -271,6 +271,8 @@ static int lenovo_se30_wdt_probe(struct platform_device *pdev)
> return -EBUSY;
>
> priv->shm_base_addr = devm_ioremap(dev, base_phys, SHM_WIN_SIZE);
> + if (!priv->shm_base_addr)
> + return -ENOMEM;
>
> priv->wdt_cfg.mod = WDT_MODULE;
> priv->wdt_cfg.idx = WDT_CFG_INDEX;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] watchdog: lenovo_se30_wdt: Fix null-ptr-deref in lenovo_se30_wdt_probe()
2025-04-24 7:16 [PATCH v1] watchdog: lenovo_se30_wdt: Fix null-ptr-deref in lenovo_se30_wdt_probe() Henry Martin
2025-04-24 12:10 ` Guenter Roeck
@ 2025-04-25 7:20 ` Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2025-04-25 7:20 UTC (permalink / raw)
To: Henry Martin, linux-watchdog, Günter Röck,
Wim Van Sebroeck; +Cc: LKML
…
> Add NULL check after devm_ioremap() to prevent this issue.
Would you get into the mood to replace the text “null-ptr-deref”
in the summary phrase?
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-25 7:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-24 7:16 [PATCH v1] watchdog: lenovo_se30_wdt: Fix null-ptr-deref in lenovo_se30_wdt_probe() Henry Martin
2025-04-24 12:10 ` Guenter Roeck
2025-04-25 7:20 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox