linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Arvind Yadav <arvind.yadav.cs@gmail.com>,
	jarkko.nikula@linux.intel.com, wsa@the-dreams.de
Cc: mika.westerberg@linux.intel.com, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [v1] i2c: busses: i2c-designware-pcidrv:- Handle return NULL error from pcim_iomap_table
Date: Thu, 22 Dec 2016 16:35:09 +0200	[thread overview]
Message-ID: <1482417309.9552.128.camel@linux.intel.com> (raw)
In-Reply-To: <1482406759-13094-1-git-send-email-arvind.yadav.cs@gmail.com>

On Thu, 2016-12-22 at 17:09 +0530, Arvind Yadav wrote:
> Here, If pcim_iomap_table will fail. It will return NULL.
> Kernel can run into a NULL-pointer dereference.
> This error check will avoid NULL pointer dereference.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
>  drivers/i2c/busses/i2c-designware-pcidrv.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c
> b/drivers/i2c/busses/i2c-designware-pcidrv.c
> index d6423cf..6a1907d 100644
> --- a/drivers/i2c/busses/i2c-designware-pcidrv.c
> +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
> @@ -235,6 +235,10 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
>  	dev->controller = controller;
>  	dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz;
>  	dev->base = pcim_iomap_table(pdev)[0];
> +	if (!dev->base) {
> +		dev_err(&pdev->dev, "I/O map table allocation
> failed\n");
> +		return -ENOMEM;
> +	}

NAK.


-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

  parent reply	other threads:[~2016-12-22 14:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-22 11:39 [v1] i2c: busses: i2c-designware-pcidrv:- Handle return NULL error from pcim_iomap_table Arvind Yadav
2016-12-22 11:50 ` Mika Westerberg
2016-12-22 14:35 ` Andy Shevchenko [this message]
2016-12-22 17:11   ` arvind Yadav

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=1482417309.9552.128.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=wsa@the-dreams.de \
    /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;
as well as URLs for NNTP newsgroup(s).