Skip to contentSkip to conversation

rtc: mt6397: Fix potential NULL dereference in mtk_rtc_probe

PATCH In review Miaoqian Lin 2 participants 2 messages Apr 4, 2022 – Apr 5, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: mt6397: Fix potential NULL dereference in mtk_rtc_probe

platform_get_resource() may return NULL, add proper check to avoid potential NULL dereferencing.

Fixes fc2979118f3f ("rtc: mediatek: Add MT6397 RTC driver")
---
 drivers/rtc/rtc-mt6397.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/rtc/rtc-mt6397.c +3 -0
index 80dc479a6ff0..07c6679366e0 100644
@@ -269,6 +269,9 @@ 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);
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Il 04/04/22 15:25, Miaoqian Lin ha scritto:

Quoted 5 lines

platform_get_resource() may return NULL, add proper check to avoid potential NULL dereferencing.

Fixes fc2979118f3f ("rtc: mediatek: Add MT6397 RTC driver")

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek