[PATCH 09/11] staging: comedi: jr3_pci: check PCI BAR 0 size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 drivers/staging/comedi/drivers/jr3_pci.c | 3 +++
 1 file changed, 3 insertions(+)

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;
-- 
2.11.0

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux