From: Ian Abbott Date: Thu, 26 Nov 2009 14:59:46 +0000 (+0000) Subject: jr3-pci: Only ioremap register space for actual number of channels on the X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fa79c726de07aff1065415767fee720e4ee9eb44;p=comedi.git 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. --- 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;