summaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-gemini.c
diff options
context:
space:
mode:
authorPan Bian <bianpan2016@163.com>2017-04-23 20:48:07 +0800
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2017-05-05 00:43:52 +0200
commit332e0d13d3c7d1e4394a513585a3d3b15a0030b8 (patch)
tree66080a3ed68c4ac691b964ce4a9f1bd43861f466 /drivers/rtc/rtc-gemini.c
parent758929005f06f954b7e1c87a1c9fdb44157b228f (diff)
rtc: gemini: add return value validation
Function devm_ioremap() will return a NULL pointer if it fails to remap IO address, and its return value should be validated before it is used. However, in function gemini_rtc_probe(), its return value is not checked. This may result in bad memory access bugs on future access, e.g. calling the function gemini_rtc_read_time(). Signed-off-by: Pan Bian <bianpan2016@163.com> Acked-by: Hans Ulli Kroll <ulli.kroll@googlemail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc/rtc-gemini.c')
-rw-r--r--drivers/rtc/rtc-gemini.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-gemini.c b/drivers/rtc/rtc-gemini.c
index ccf0dbadb62d..5279390bb42d 100644
--- a/drivers/rtc/rtc-gemini.c
+++ b/drivers/rtc/rtc-gemini.c
@@ -139,6 +139,8 @@ static int gemini_rtc_probe(struct platform_device *pdev)
rtc->rtc_base = devm_ioremap(dev, res->start,
resource_size(res));
+ if (!rtc->rtc_base)
+ return -ENOMEM;
ret = devm_request_irq(dev, rtc->rtc_irq, gemini_rtc_interrupt,
IRQF_SHARED, pdev->name, dev);