Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1546280 > unrolled thread
| Started by | Arvind Yadav <arvind.yadav.cs@gmail.com> |
|---|---|
| First post | 2016-12-22 12:50 +0100 |
| Last post | 2016-12-22 18:20 +0100 |
| Articles | 4 — 4 participants |
Back to article view | Back to linux.kernel
[v1] i2c: busses: i2c-designware-pcidrv:- Handle return NULL error from pcim_iomap_table Arvind Yadav <arvind.yadav.cs@gmail.com> - 2016-12-22 12:50 +0100
Re: [v1] i2c: busses: i2c-designware-pcidrv:- Handle return NULL error from pcim_iomap_table Mika Westerberg <mika.westerberg@linux.intel.com> - 2016-12-22 13:00 +0100
Re: [v1] i2c: busses: i2c-designware-pcidrv:- Handle return NULL error from pcim_iomap_table Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-12-22 15:40 +0100
Re: [v1] i2c: busses: i2c-designware-pcidrv:- Handle return NULL error from pcim_iomap_table arvind Yadav <arvind.yadav.cs@gmail.com> - 2016-12-22 18:20 +0100
| From | Arvind Yadav <arvind.yadav.cs@gmail.com> |
|---|---|
| Date | 2016-12-22 12:50 +0100 |
| Subject | [v1] i2c: busses: i2c-designware-pcidrv:- Handle return NULL error from pcim_iomap_table |
| Message-ID | <sRa2J-wg-3@gated-at.bofh.it> |
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;
+ }
dev->dev = &pdev->dev;
dev->irq = pdev->irq;
--
1.7.9.5
[toc] | [next] | [standalone]
| From | Mika Westerberg <mika.westerberg@linux.intel.com> |
|---|---|
| Date | 2016-12-22 13:00 +0100 |
| Subject | Re: [v1] i2c: busses: i2c-designware-pcidrv:- Handle return NULL error from pcim_iomap_table |
| Message-ID | <sRacp-zp-1@gated-at.bofh.it> |
| In reply to | #1546280 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Andy Shevchenko <andriy.shevchenko@linux.intel.com> |
|---|---|
| Date | 2016-12-22 15:40 +0100 |
| Subject | Re: [v1] i2c: busses: i2c-designware-pcidrv:- Handle return NULL error from pcim_iomap_table |
| Message-ID | <sRcHg-2c2-9@gated-at.bofh.it> |
| In reply to | #1546280 |
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
[toc] | [prev] | [next] | [standalone]
| From | arvind Yadav <arvind.yadav.cs@gmail.com> |
|---|---|
| Date | 2016-12-22 18:20 +0100 |
| Subject | Re: [v1] i2c: busses: i2c-designware-pcidrv:- Handle return NULL error from pcim_iomap_table |
| Message-ID | <sRfc5-3Sa-11@gated-at.bofh.it> |
| In reply to | #1546399 |
Yes, It will not fail. Sorry for the noise.
Thanks
-Arvind
On Thursday 22 December 2016 08:05 PM, Andy Shevchenko wrote:
> 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.
>
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web