From fa79c726de07aff1065415767fee720e4ee9eb44 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 26 Nov 2009 14:59:46 +0000 Subject: [PATCH] jr3-pci: Only ioremap register space for actual number of channels on the card. Also, check result of ioremap() for failure. Thanks to Anders Blomdell for input and Sami Hussein for testing. --- comedi/drivers/jr3_pci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/comedi/drivers/jr3_pci.c b/comedi/drivers/jr3_pci.c index 349e9098..0482a3fb 100644 --- a/comedi/drivers/jr3_pci.c +++ b/comedi/drivers/jr3_pci.c @@ -827,7 +827,11 @@ static int jr3_pci_attach(comedi_device * dev, comedi_devconfig * it) return -EIO; } devpriv->pci_enabled = 1; - devpriv->iobase = ioremap(pci_resource_start(card, 0), sizeof(jr3_t)); + devpriv->iobase = ioremap(pci_resource_start(card, 0), + offsetof(jr3_t, channel[devpriv->n_channels])); + if (!devpriv->iobase) { + return -ENOMEM; + } result = alloc_subdevices(dev, devpriv->n_channels); if (result < 0) goto out; -- 2.26.2