Skip to content

Commit

Permalink
firewire: ohci: sanity-check MMIO resource
Browse files Browse the repository at this point in the history
pci_request_region() does not fail on resources that have not been
allocated by the BIOS or by the kernel, so to avoid accessing
registers that are not there, we have to check for this explicitly.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
  • Loading branch information
Clemens Ladisch authored and Stefan Richter committed Jun 4, 2012
1 parent 9d60ef2 commit 7baab9a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/firewire/ohci.c
Original file line number Diff line number Diff line change
Expand Up @@ -3545,6 +3545,13 @@ static int __devinit pci_probe(struct pci_dev *dev,

INIT_WORK(&ohci->bus_reset_work, bus_reset_work);

if (!(pci_resource_flags(dev, 0) & IORESOURCE_MEM) ||
pci_resource_len(dev, 0) < OHCI1394_REGISTER_SIZE) {
dev_err(&dev->dev, "invalid MMIO resource\n");
err = -ENXIO;
goto fail_disable;
}

err = pci_request_region(dev, 0, ohci_driver_name);
if (err) {
dev_err(&dev->dev, "MMIO resource unavailable\n");
Expand Down

0 comments on commit 7baab9a

Please sign in to comment.