Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752676AbdD0EXF (ORCPT ); Thu, 27 Apr 2017 00:23:05 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34191 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751634AbdD0EW7 (ORCPT ); Thu, 27 Apr 2017 00:22:59 -0400 Date: Thu, 27 Apr 2017 06:22:54 +0200 (CEST) From: Hans Ulli Kroll X-X-Sender: elektroman@T520 To: Pan Bian cc: Hans Ulli Kroll , Alessandro Zummo , Alexandre Belloni , rtc-linux@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Pan Bian Subject: Re: [PATCH 1/1] rtc: gemini: add return value validation In-Reply-To: <1492951687-16777-1-git-send-email-bianpan201602@163.com> Message-ID: References: <1492951687-16777-1-git-send-email-bianpan201602@163.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1129 Lines: 38 HI Pan, On Sun, 23 Apr 2017, Pan Bian wrote: > 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 > > > Acked-by: Hans Ulli Kroll