Skip to content

Commit

Permalink
isdn: hfcpci: fix potential NULL pointer dereference
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kangjie Lu authored and David S. Miller committed Mar 12, 2019
1 parent a3b1933 commit 1001049
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/isdn/hardware/mISDN/hfcpci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1001049

Please sign in to comment.