2016-12-22 12:07:57

by Arvind Yadav

[permalink] [raw]
Subject: [v1] mmc: host: dw_mmc-pci:- Handle return NULL error from pcim_iomap_table

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 <[email protected]>
---
drivers/mmc/host/dw_mmc-pci.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/host/dw_mmc-pci.c b/drivers/mmc/host/dw_mmc-pci.c
index ab82796..f42d302 100644
--- a/drivers/mmc/host/dw_mmc-pci.c
+++ b/drivers/mmc/host/dw_mmc-pci.c
@@ -61,6 +61,8 @@ static int dw_mci_pci_probe(struct pci_dev *pdev,
return ret;

host->regs = pcim_iomap_table(pdev)[PCI_BAR_NO];
+ if (!host->regs)
+ return -ENOMEM;

pci_set_master(pdev);

--
1.7.9.5


2016-12-22 17:13:01

by Arvind Yadav

[permalink] [raw]
Subject: Re: [v1] mmc: host: dw_mmc-pci:- Handle return NULL error from pcim_iomap_table

Ignore this change. Sorry for noise.

Thanks
-Arvind

On Thursday 22 December 2016 05:36 PM, 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 <[email protected]>
> ---
> drivers/mmc/host/dw_mmc-pci.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/mmc/host/dw_mmc-pci.c b/drivers/mmc/host/dw_mmc-pci.c
> index ab82796..f42d302 100644
> --- a/drivers/mmc/host/dw_mmc-pci.c
> +++ b/drivers/mmc/host/dw_mmc-pci.c
> @@ -61,6 +61,8 @@ static int dw_mci_pci_probe(struct pci_dev *pdev,
> return ret;
>
> host->regs = pcim_iomap_table(pdev)[PCI_BAR_NO];
> + if (!host->regs)
> + return -ENOMEM;
>
> pci_set_master(pdev);
>