All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Arvind Yadav <arvind.yadav.cs@gmail.com>
Cc: jarkko.nikula@linux.intel.com, wsa@the-dreams.de,
	andriy.shevchenko@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 13:50:33 +0200	[thread overview]
Message-ID: <20161222115033.GO1460@lahna.fi.intel.com> (raw)
In-Reply-To: <1482406759-13094-1-git-send-email-arvind.yadav.cs@gmail.com>

On Thu, Dec 22, 2016 at 05:09:19PM +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;

Are you sure this can actually happen?

IIRC pcim_iomap_regions() (which is called before this) makes sure the
BARs you access here are valid.

  reply	other threads:[~2016-12-22 11:51 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 [this message]
2016-12-22 14:35 ` Andy Shevchenko
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=20161222115033.GO1460@lahna.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.