jr3-pci: Only ioremap register space for actual number of channels on the
authorIan Abbott <abbotti@mev.co.uk>
Thu, 26 Nov 2009 14:59:46 +0000 (14:59 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Thu, 26 Nov 2009 14:59:46 +0000 (14:59 +0000)
card.  Also, check result of ioremap() for failure.

Thanks to Anders Blomdell for input and Sami Hussein for testing.

comedi/drivers/jr3_pci.c

index 349e90982aedc937f441173216e187961ce1560b..0482a3fb96bf5307dd31412818ae25bcf32b1ffd 100644 (file)
@@ -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;