Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: ulli.kroll@googlemail.com (Hans Ulli Kroll)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/1] rtc: gemini: add return value validation
Date: Thu, 27 Apr 2017 06:22:54 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LNX.2.00.1704270620490.16259@T520> (raw)
In-Reply-To: <1492951687-16777-1-git-send-email-bianpan201602@163.com>

HI Pan,

On Sun, 23 Apr 2017, Pan Bian wrote:

> From: Pan Bian <bianpan2016@163.com>
> 
> 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>
> ---
>  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 <ulli.kroll@googlemail.com>

  reply	other threads:[~2017-04-27  4:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-23 12:48 [PATCH 1/1] rtc: gemini: add return value validation Pan Bian
2017-04-27  4:22 ` Hans Ulli Kroll [this message]
2017-05-04 22:58 ` Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.00.1704270620490.16259@T520 \
    --to=ulli.kroll@googlemail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox