Skip to content

Commit

Permalink
rtc: mt6397: check return value after calling platform_get_resource()
Browse files Browse the repository at this point in the history
[ Upstream commit d3b43eb ]

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Fixes: fc29791 ("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>
  • Loading branch information
Yang Yingliang authored and gregkh committed Jun 14, 2022
1 parent d54a51b commit 82bfea3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/rtc/rtc-mt6397.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 82bfea3

Please sign in to comment.