platform_get_resource() may return NULL, add proper check to avoid potential NULL dereferencing. Fixes: fc2979118f3f ("rtc: mediatek: Add MT6397 RTC driver") Signed-off-by: Miaoqian Lin <linmq006@xxxxxxxxx> --- drivers/rtc/rtc-mt6397.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c index 80dc479a6ff0..07c6679366e0 100644 --- a/drivers/rtc/rtc-mt6397.c +++ b/drivers/rtc/rtc-mt6397.c @@ -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); -- 2.17.1