2022-05-06 00:53:00

by Yang Yingliang

[permalink] [raw]
Subject: [PATCH] rtc: mt6397: check return value after calling platform_get_resource()

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Fixes: fc2979118f3f ("rtc: mediatek: Add MT6397 RTC driver")
Signed-off-by: Yang Yingliang <[email protected]>
---
drivers/rtc/rtc-mt6397.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c
index 80dc479a6ff0..1d297af80f87 100644
--- a/drivers/rtc/rtc-mt6397.c
+++ b/drivers/rtc/rtc-mt6397.c
@@ -269,6 +269,8 @@ static int mtk_rtc_probe(struct platform_device *pdev)
return -ENOMEM;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res)
+ return -EINVAL;
rtc->addr_base = res->start;

rtc->data = of_device_get_match_data(&pdev->dev);
--
2.25.1



Subject: Re: [PATCH] rtc: mt6397: check return value after calling platform_get_resource()

Il 05/05/22 14:50, Yang Yingliang ha scritto:
> It will cause null-ptr-deref if platform_get_resource() returns NULL,
> we need check the return value.
>
> Fixes: fc2979118f3f ("rtc: mediatek: Add MT6397 RTC driver")
> Signed-off-by: Yang Yingliang <[email protected]>

Reviewed-by: AngeloGioacchino Del Regno <[email protected]>

2022-05-19 15:14:08

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH] rtc: mt6397: check return value after calling platform_get_resource()

On Thu, 5 May 2022 20:50:43 +0800, Yang Yingliang wrote:
> It will cause null-ptr-deref if platform_get_resource() returns NULL,
> we need check the return value.
>
>

Applied, thanks!

[1/1] rtc: mt6397: check return value after calling platform_get_resource()
commit: d3b43eb505bffb8e4cdf6800c15660c001553fe6

Best regards,

--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com