]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
staging: comedi: jr3_pci: check PCI BAR 0 size
authorIan Abbott <abbotti@mev.co.uk>
Wed, 8 Mar 2017 18:44:31 +0000 (18:44 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 12 Mar 2017 13:57:00 +0000 (14:57 +0100)
The various supported boards have different numbers of subdevices from 1
to 4.  Each subdevice needs a block of registers in PCI BAR 0.  Check
the region is large enough for the required number of subdevices.
Return an error from `jr3_pci_auto_attach()` if it is too small.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/jr3_pci.c

index c0ae92217932d9dfcf6a8aea584f7cc316f9cb23..a21344e1a4c39505310e912e55bf0fe23d5f3028 100644 (file)
@@ -705,6 +705,9 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
        if (ret)
                return ret;
 
+       if (pci_resource_len(pcidev, 0) < board->n_subdevs * sizeof(*block))
+               return -ENXIO;
+
        dev->mmio = pci_ioremap_bar(pcidev, 0);
        if (!dev->mmio)
                return -ENOMEM;