2022-07-22 03:22:15

by williamsukatube

[permalink] [raw]
Subject: [PATCH] watchdog: armada_37xx_wdt: check the return value of devm_ioremap() in armada_37xx_wdt_probe()

From: William Dean <[email protected]>

The function devm_ioremap() in armada_37xx_wdt_probe() can fail, so
its return value should be checked.

Fixes: 54e3d9b518c8a ("watchdog: Add support for Armada 37xx CPU watchdog")
Reported-by: Hacash Robot <[email protected]>
Signed-off-by: William Dean <[email protected]>
---
drivers/watchdog/armada_37xx_wdt.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/watchdog/armada_37xx_wdt.c b/drivers/watchdog/armada_37xx_wdt.c
index 1635f421ef2c..854b1cc723cb 100644
--- a/drivers/watchdog/armada_37xx_wdt.c
+++ b/drivers/watchdog/armada_37xx_wdt.c
@@ -274,6 +274,8 @@ static int armada_37xx_wdt_probe(struct platform_device *pdev)
if (!res)
return -ENODEV;
dev->reg = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+ if (!dev->reg)
+ return -ENOMEM;

/* init clock */
dev->clk = devm_clk_get(&pdev->dev, NULL);
--
2.25.1


2022-07-22 04:22:25

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH] watchdog: armada_37xx_wdt: check the return value of devm_ioremap() in armada_37xx_wdt_probe()

On 7/21/22 20:09, [email protected] wrote:
> From: William Dean <[email protected]>
>
> The function devm_ioremap() in armada_37xx_wdt_probe() can fail, so
> its return value should be checked.
>
> Fixes: 54e3d9b518c8a ("watchdog: Add support for Armada 37xx CPU watchdog")
> Reported-by: Hacash Robot <[email protected]>
> Signed-off-by: William Dean <[email protected]>

Reviewed-by: Guenter Roeck <[email protected]>

> ---
> drivers/watchdog/armada_37xx_wdt.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/watchdog/armada_37xx_wdt.c b/drivers/watchdog/armada_37xx_wdt.c
> index 1635f421ef2c..854b1cc723cb 100644
> --- a/drivers/watchdog/armada_37xx_wdt.c
> +++ b/drivers/watchdog/armada_37xx_wdt.c
> @@ -274,6 +274,8 @@ static int armada_37xx_wdt_probe(struct platform_device *pdev)
> if (!res)
> return -ENODEV;
> dev->reg = devm_ioremap(&pdev->dev, res->start, resource_size(res));
> + if (!dev->reg)
> + return -ENOMEM;
>
> /* init clock */
> dev->clk = devm_clk_get(&pdev->dev, NULL);

2022-07-22 07:17:26

by Marek Behún

[permalink] [raw]
Subject: Re: [PATCH] watchdog: armada_37xx_wdt: check the return value of devm_ioremap() in armada_37xx_wdt_probe()

On Fri, 22 Jul 2022 11:09:38 +0800
[email protected] wrote:

> From: William Dean <[email protected]>
>
> The function devm_ioremap() in armada_37xx_wdt_probe() can fail, so
> its return value should be checked.
>
> Fixes: 54e3d9b518c8a ("watchdog: Add support for Armada 37xx CPU watchdog")
> Reported-by: Hacash Robot <[email protected]>
> Signed-off-by: William Dean <[email protected]>
> ---
> drivers/watchdog/armada_37xx_wdt.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/watchdog/armada_37xx_wdt.c b/drivers/watchdog/armada_37xx_wdt.c
> index 1635f421ef2c..854b1cc723cb 100644
> --- a/drivers/watchdog/armada_37xx_wdt.c
> +++ b/drivers/watchdog/armada_37xx_wdt.c
> @@ -274,6 +274,8 @@ static int armada_37xx_wdt_probe(struct platform_device *pdev)
> if (!res)
> return -ENODEV;
> dev->reg = devm_ioremap(&pdev->dev, res->start, resource_size(res));
> + if (!dev->reg)
> + return -ENOMEM;
>
> /* init clock */
> dev->clk = devm_clk_get(&pdev->dev, NULL);

Reviewed-by: Marek Behún <[email protected]>