mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Abbott <abbotti@mev.co.uk>
To: Pan Bian <bianpan201602@163.com>,
	H Hartley Sweeten <hsweeten@visionengravers.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	Pan Bian <bianpan2016@163.com>
Subject: Re: [PATCH 1/1] staging: comedi: addi_apci_3xxx: check return value
Date: Mon, 24 Apr 2017 10:28:35 +0100	[thread overview]
Message-ID: <7d20a03b-869a-ffe3-b3e2-28a3350398b8@mev.co.uk> (raw)
In-Reply-To: <1492941175-9422-1-git-send-email-bianpan201602@163.com>

On 23/04/17 10:52, Pan Bian wrote:
> From: Pan Bian <bianpan2016@163.com>
>
> Function pci_ioremap_bar() will return a NULL pointer if there is no
> enough memory. However, in function apci3xxx_auto_attach(), the return
> value of function pci_ioremap_bar() is not validated. This may result in
> NULL dereference in following access to dev->mmio. This patch fixes the
> bug.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
>  drivers/staging/comedi/drivers/addi_apci_3xxx.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
> index b6af3eb..a07d5bd 100644
> --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c
> +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
> @@ -787,6 +787,8 @@ static int apci3xxx_auto_attach(struct comedi_device *dev,
>
>  	dev->iobase = pci_resource_start(pcidev, 2);
>  	dev->mmio = pci_ioremap_bar(pcidev, 3);
> +	if (!dev->mmio)
> +		return -ENOMEM;
>
>  	if (pcidev->irq > 0) {
>  		ret = request_irq(pcidev->irq, apci3xxx_irq_handler,
>

Looks good. Thanks for the fix.

Reviewed-by: Ian Abbott <abbotti@mev.co.uk>

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-

      reply	other threads:[~2017-04-24  9:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-23  9:52 Pan Bian
2017-04-24  9:28 ` Ian Abbott [this message]

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=7d20a03b-869a-ffe3-b3e2-28a3350398b8@mev.co.uk \
    --to=abbotti@mev.co.uk \
    --cc=bianpan201602@163.com \
    --cc=bianpan2016@163.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hsweeten@visionengravers.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®