watchdog: lenovo_se30_wdt: Fix null-ptr-deref in lenovo_se30_wdt_probe()
PATCH 1/1 watchdog: lenovo_se30_wdt: Fix null-ptr-deref in lenovo_se30_wdt_probe()
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 <[email protected]>
--- drivers/watchdog/lenovo_se30_wdt.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/watchdog/lenovo_se30_wdt.c +2 -0
@@ -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 ;
Signature · 1 line
2.34.1
Quoted 8 lines · 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 <[email protected]>
Reviewed-by Guenter Roeck <[email protected]>
Quoted 17 lines
--- drivers/watchdog/lenovo_se30_wdt.c | 2 ++ 1 file changed, 2 insertions(+)drivers/watchdog/lenovo_se30_wdt.c +2
-0@@ -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 ;
…
Quoted 1 line
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