[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20161222115033.GO1460@lahna.fi.intel.com>
Date: Thu, 22 Dec 2016 13:50:33 +0200
From: Mika Westerberg <mika.westerberg@...ux.intel.com>
To: Arvind Yadav <arvind.yadav.cs@...il.com>
Cc: jarkko.nikula@...ux.intel.com, wsa@...-dreams.de,
andriy.shevchenko@...ux.intel.com, linux-i2c@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [v1] i2c: busses: i2c-designware-pcidrv:- Handle return NULL
error from pcim_iomap_table
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@...il.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.
Powered by blists - more mailing lists