summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-mt6397.c
diff options
context:
space:
mode:
authorYang Yingliang <yangyingliang@huawei.com>2022-05-05 14:50:43 +0200
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2022-05-19 12:05:48 +0200
commitd3b43eb505bffb8e4cdf6800c15660c001553fe6 (patch)
tree255ab1ff29940c40a29ca1edfecea26e94d299b0 /drivers/rtc/rtc-mt6397.c
parentrtc: rzn1: fix platform_no_drv_owner.cocci warning (diff)
downloadlinux-d3b43eb505bffb8e4cdf6800c15660c001553fe6.tar.xz
linux-d3b43eb505bffb8e4cdf6800c15660c001553fe6.zip
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 <yangyingliang@huawei.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220505125043.1594771-1-yangyingliang@huawei.com
Diffstat (limited to 'drivers/rtc/rtc-mt6397.c')
-rw-r--r--drivers/rtc/rtc-mt6397.c2
1 files changed, 2 insertions, 0 deletions
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);