summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Yingliang <yangyingliang@huawei.com>2022-05-05 20:50:43 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-06-14 16:59:32 +0200
commit6ecd4d5c28408df36a1a6f0b1973f633c949ac1f (patch)
tree294f991b67e3049bb3ed5a6d00f34fb951693de6
parent3448aa3b941999f5fed7570ad6bad79972cbd18c (diff)
downloadlinux-stable-6ecd4d5c28408df36a1a6f0b1973f633c949ac1f.tar.gz
rtc: mt6397: check return value after calling platform_get_resource()
[ Upstream commit d3b43eb505bffb8e4cdf6800c15660c001553fe6 ] 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 Signed-off-by: Sasha Levin <sashal@kernel.org>
-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 964ed91416e1..671b6d275da3 100644
--- a/drivers/rtc/rtc-mt6397.c
+++ b/drivers/rtc/rtc-mt6397.c
@@ -339,6 +339,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->irq = platform_get_irq(pdev, 0);