Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1045405AbdDWMt6 (ORCPT ); Sun, 23 Apr 2017 08:49:58 -0400 Received: from m50-132.163.com ([123.125.50.132]:44919 "EHLO m50-132.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1045306AbdDWMtt (ORCPT ); Sun, 23 Apr 2017 08:49:49 -0400 From: Pan Bian To: Hans Ulli Kroll , Alessandro Zummo , Alexandre Belloni , rtc-linux@googlegroups.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] rtc: gemini: add return value validation Date: Sun, 23 Apr 2017 20:48:07 +0800 Message-Id: <1492951687-16777-1-git-send-email-bianpan201602@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DNGowAC3lR6HovxYW24nAA--.940S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrur4rXF1rKr1kJr1DZFyrJFb_yoWDGFc_Wa 1xur97GrZ7Gr1UKr1jyr43urWYk3Wjvr1kWr4rKa9akr17Zr4DGay7ZryDtr18Zw4xKF98 GryqvFyF934a9jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUnG-e5UUUUU== X-Originating-IP: [123.118.194.153] X-CM-SenderInfo: held01tdqsiiqwqsqiywtou0bp/1tbiWAnC4FUMAewlMQAAsT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 962 Lines: 29 From: Pan Bian 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 --- drivers/rtc/rtc-gemini.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/rtc/rtc-gemini.c b/drivers/rtc/rtc-gemini.c index ccf0dba..5279390 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); -- 1.9.1