summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2017-03-08 18:44:31 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-12 14:57:00 +0100
commit8abde9acdfc82aacbfd96e65fe416c29c4856500 (patch)
treeb13e813aed590748af697ff9cfd2b5786913117c /drivers/staging/comedi/drivers
parent7cb1c5c2cd5fe2d4303eee415ca2ed207bd932a5 (diff)
staging: comedi: jr3_pci: check PCI BAR 0 size
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>
Diffstat (limited to 'drivers/staging/comedi/drivers')
-rw-r--r--drivers/staging/comedi/drivers/jr3_pci.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c
index c0ae92217932..a21344e1a4c3 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -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;