Skip to contentSkip to conversation

mmc: host: dw_mmc-pci:- Handle return NULL error from pcim_iomap_table

PATCH In review Arvind Yadav 1 participant 2 messages Dec 22, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/mmc/host/dw_mmc-pci.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/host/dw_mmc-pci.c +2 -0
index ab82796..f42d302 100644
@@ -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);
 
Signature · 1 line
1.7.9.5
#1 lore raw

Ignore this change. Sorry for noise.

Thanks
-Arvind

Quoted 22 lines · Arvind Yadav

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.

---
  drivers/mmc/host/dw_mmc-pci.c |    2 ++
  1 file changed, 2 insertions(+)
drivers/mmc/host/dw_mmc-pci.c +2 -0
index ab82796..f42d302 100644
@@ -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);