Skip to content

Commit 1001049

Browse files
kengiterdavem330
authored andcommitted
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>
1 parent a3b1933 commit 1001049

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/isdn/hardware/mISDN/hfcpci.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,10 +2032,19 @@ setup_hw(struct hfc_pci *hc)
20322032
hc->hw.fifos = buffer;
20332033
pci_write_config_dword(hc->pdev, 0x80, hc->hw.dmahandle);
20342034
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+
20352043
printk(KERN_INFO
20362044
"HFC-PCI: defined at mem %#lx fifo %#lx(%#lx) IRQ %d HZ %d\n",
20372045
(u_long) hc->hw.pci_io, (u_long) hc->hw.fifos,
20382046
(u_long) hc->hw.dmahandle, hc->irq, HZ);
2047+
20392048
/* enable memory mapped ports, disable busmaster */
20402049
pci_write_config_word(hc->pdev, PCI_COMMAND, PCI_ENA_MEMIO);
20412050
hc->hw.int_m2 = 0;

0 commit comments

Comments
 (0)