linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: mt6397: check return value after calling platform_get_resource()
@ 2022-05-05 12:50 Yang Yingliang
  2022-05-05 14:55 ` AngeloGioacchino Del Regno
  2022-05-19 10:06 ` Alexandre Belloni
  0 siblings, 2 replies; 3+ messages in thread
From: Yang Yingliang @ 2022-05-05 12:50 UTC (permalink / raw)
  To: linux-kernel, linux-rtc, linux-mediatek, linux-arm-kernel
  Cc: eddie.huang, sean.wang, a.zummo, alexandre.belloni, lee.jones

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 <yangyingliang@huawei.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rtc: mt6397: check return value after calling platform_get_resource()
  2022-05-05 12:50 [PATCH] rtc: mt6397: check return value after calling platform_get_resource() Yang Yingliang
@ 2022-05-05 14:55 ` AngeloGioacchino Del Regno
  2022-05-19 10:06 ` Alexandre Belloni
  1 sibling, 0 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-05-05 14:55 UTC (permalink / raw)
  To: Yang Yingliang, linux-kernel, linux-rtc, linux-mediatek,
	linux-arm-kernel
  Cc: eddie.huang, sean.wang, a.zummo, alexandre.belloni, lee.jones

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 <yangyingliang@huawei.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rtc: mt6397: check return value after calling platform_get_resource()
  2022-05-05 12:50 [PATCH] rtc: mt6397: check return value after calling platform_get_resource() Yang Yingliang
  2022-05-05 14:55 ` AngeloGioacchino Del Regno
@ 2022-05-19 10:06 ` Alexandre Belloni
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Belloni @ 2022-05-19 10:06 UTC (permalink / raw)
  To: linux-rtc, linux-kernel, linux-mediatek, linux-arm-kernel,
	Yang Yingliang
  Cc: a.zummo, sean.wang, lee.jones, eddie.huang

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-19 10:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 12:50 [PATCH] rtc: mt6397: check return value after calling platform_get_resource() Yang Yingliang
2022-05-05 14:55 ` AngeloGioacchino Del Regno
2022-05-19 10:06 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).