summaryrefslogtreecommitdiffstats
path: root/drivers/isdn
diff options
context:
space:
mode:
authorKangjie Lu2019-03-12 06:54:55 +0100
committerDavid S. Miller2019-03-12 22:36:02 +0100
commit10010493c1261ca3d7444d372f281009890a5ff7 (patch)
treeb0e0af67f213a58f5c05a551fcd55d261eaf8b3b /drivers/isdn
parentMerge tag 'mlx5-fixes-2019-03-11' of git://git.kernel.org/pub/scm/linux/kerne... (diff)
downloadkernel-qcow2-linux-10010493c1261ca3d7444d372f281009890a5ff7.tar.gz
kernel-qcow2-linux-10010493c1261ca3d7444d372f281009890a5ff7.tar.xz
kernel-qcow2-linux-10010493c1261ca3d7444d372f281009890a5ff7.zip
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>
Diffstat (limited to 'drivers/isdn')
-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)
hc->hw.fifos = buffer;
pci_write_config_dword(hc->pdev, 0x80, hc->hw.dmahandle);
hc->hw.pci_io = ioremap((ulong) hc->hw.pci_io, 256);
+ if (unlikely(!hc->hw.pci_io)) {
+ printk(KERN_WARNING
+ "HFC-PCI: Error in ioremap for PCI!\n");
+ pci_free_consistent(hc->pdev, 0x8000, hc->hw.fifos,
+ hc->hw.dmahandle);
+ return 1;
+ }
+
printk(KERN_INFO
"HFC-PCI: defined at mem %#lx fifo %#lx(%#lx) IRQ %d HZ %d\n",
(u_long) hc->hw.pci_io, (u_long) hc->hw.fifos,
(u_long) hc->hw.dmahandle, hc->irq, HZ);
+
/* enable memory mapped ports, disable busmaster */
pci_write_config_word(hc->pdev, PCI_COMMAND, PCI_ENA_MEMIO);
hc->hw.int_m2 = 0;