2021-12-20 08:38:34

by Jiasheng Jiang

[permalink] [raw]
Subject: [PATCH] rtc: mt6397: Check for null res pointer

The return value of platform_get_resource() needs to be checked.
To avoid use of error pointer in case that there is no suitable
resource.

Fixes: d28c74c10751 ("power: reset: add driver for mt6323 poweroff")
Signed-off-by: Jiasheng Jiang <[email protected]>
---
drivers/power/reset/mt6323-poweroff.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/power/reset/mt6323-poweroff.c b/drivers/power/reset/mt6323-poweroff.c
index 0532803e6cbc..d90e76fcb938 100644
--- a/drivers/power/reset/mt6323-poweroff.c
+++ b/drivers/power/reset/mt6323-poweroff.c
@@ -57,6 +57,9 @@ static int mt6323_pwrc_probe(struct platform_device *pdev)
return -ENOMEM;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -EINVAL;
+
pwrc->base = res->start;
pwrc->regmap = mt6397_chip->regmap;
pwrc->dev = &pdev->dev;
--
2.25.1



2022-01-03 17:40:01

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH] rtc: mt6397: Check for null res pointer

Hi,

On Mon, Dec 20, 2021 at 04:38:11PM +0800, Jiasheng Jiang wrote:
> The return value of platform_get_resource() needs to be checked.
> To avoid use of error pointer in case that there is no suitable
> resource.
>
> Fixes: d28c74c10751 ("power: reset: add driver for mt6323 poweroff")
> Signed-off-by: Jiasheng Jiang <[email protected]>
> ---

Thanks, I fixed the subject and queued the patch.

-- Sebastian

> drivers/power/reset/mt6323-poweroff.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/power/reset/mt6323-poweroff.c b/drivers/power/reset/mt6323-poweroff.c
> index 0532803e6cbc..d90e76fcb938 100644
> --- a/drivers/power/reset/mt6323-poweroff.c
> +++ b/drivers/power/reset/mt6323-poweroff.c
> @@ -57,6 +57,9 @@ static int mt6323_pwrc_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res)
> + return -EINVAL;
> +
> pwrc->base = res->start;
> pwrc->regmap = mt6397_chip->regmap;
> pwrc->dev = &pdev->dev;
> --
> 2.25.1
>


Attachments:
(No filename) (1.02 kB)
signature.asc (833.00 B)
Download all attachments