aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKangjie Lu <kjlu@umn.edu>2019-03-12 01:54:55 -0400
committerDavid S. Miller <davem@davemloft.net>2019-03-12 17:36:02 -0400
commit10010493c1261ca3d7444d372f281009890a5ff7 (patch)
treeb0e0af67f213a58f5c05a551fcd55d261eaf8b3b
parenta3b1933d34d5bb26d7503752e3528315a9e28339 (diff)
isdn: hfcpci: fix potential NULL pointer dereference
In case ioremap fails, the fix releases resources and returns. The following printk is for logging purpose and thus is preserved. Signed-off-by: Kangjie Lu <kjlu@umn.edu> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/isdn/hardware/mISDN/hfcpci.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
index ebb3fa2e1d00..362aa5450a5e 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -2032,10 +2032,19 @@ setup_hw(struct hfc_pci *hc)
2032 hc->hw.fifos = buffer; 2032 hc->hw.fifos = buffer;
2033 pci_write_config_dword(hc->pdev, 0x80, hc->hw.dmahandle); 2033 pci_write_config_dword(hc->pdev, 0x80, hc->hw.dmahandle);
2034 hc->hw.pci_io = ioremap((ulong) hc->hw.pci_io, 256); 2034 hc->hw.pci_io = ioremap((ulong) hc->hw.pci_io, 256);
2035 if (unlikely(!hc->hw.pci_io)) {
2036 printk(KERN_WARNING
2037 "HFC-PCI: Error in ioremap for PCI!\n");
2038 pci_free_consistent(hc->pdev, 0x8000, hc->hw.fifos,
2039 hc->hw.dmahandle);
2040 return 1;
2041 }
2042
2035 printk(KERN_INFO 2043 printk(KERN_INFO
2036 "HFC-PCI: defined at mem %#lx fifo %#lx(%#lx) IRQ %d HZ %d\n", 2044 "HFC-PCI: defined at mem %#lx fifo %#lx(%#lx) IRQ %d HZ %d\n",
2037 (u_long) hc->hw.pci_io, (u_long) hc->hw.fifos, 2045 (u_long) hc->hw.pci_io, (u_long) hc->hw.fifos,
2038 (u_long) hc->hw.dmahandle, hc->irq, HZ); 2046 (u_long) hc->hw.dmahandle, hc->irq, HZ);
2047
2039 /* enable memory mapped ports, disable busmaster */ 2048 /* enable memory mapped ports, disable busmaster */
2040 pci_write_config_word(hc->pdev, PCI_COMMAND, PCI_ENA_MEMIO); 2049 pci_write_config_word(hc->pdev, PCI_COMMAND, PCI_ENA_MEMIO);
2041 hc->hw.int_m2 = 0; 2050 hc->hw.int_m2 = 0;