diff options
author | Ian Abbott <abbotti@mev.co.uk> | 2009-11-30 05:59:27 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-23 14:27:46 -0500 |
commit | fa5c5f4ce0c9ba03a670c640cad17e14cb35678b (patch) | |
tree | b0d5e18a0e01ffc29098ffdcc281ff2421568d39 | |
parent | d103bef45180892515345e761f42db5601de9846 (diff) |
Staging: comedi: jr3_pci: Don't ioremap too much space. Check result.
For the JR3/PCI cards, the size of the PCIBAR0 region depends on the
number of channels. Don't try and ioremap space for 4 channels if the
card has fewer channels. Also check for ioremap failure.
Thanks to Anders Blomdell for input and Sami Hussein for testing.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/comedi/drivers/jr3_pci.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index 0d2c2eb23b23..bd397840dcba 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c | |||
@@ -849,8 +849,11 @@ static int jr3_pci_attach(struct comedi_device *dev, | |||
849 | } | 849 | } |
850 | 850 | ||
851 | devpriv->pci_enabled = 1; | 851 | devpriv->pci_enabled = 1; |
852 | devpriv->iobase = | 852 | devpriv->iobase = ioremap(pci_resource_start(card, 0), |
853 | ioremap(pci_resource_start(card, 0), sizeof(struct jr3_t)); | 853 | offsetof(struct jr3_t, channel[devpriv->n_channels])); |
854 | if (!devpriv->iobase) | ||
855 | return -ENOMEM; | ||
856 | |||
854 | result = alloc_subdevices(dev, devpriv->n_channels); | 857 | result = alloc_subdevices(dev, devpriv->n_channels); |
855 | if (result < 0) | 858 | if (result < 0) |
856 | goto out; | 859 | goto out; |