Skip to content

Commit

Permalink
Staging: comedi: jr3_pci: Don't ioremap too much space. Check result.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Dec 23, 2009
1 parent d103bef commit fa5c5f4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/staging/comedi/drivers/jr3_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,11 @@ static int jr3_pci_attach(struct comedi_device *dev,
}

devpriv->pci_enabled = 1;
devpriv->iobase =
ioremap(pci_resource_start(card, 0), sizeof(struct jr3_t));
devpriv->iobase = ioremap(pci_resource_start(card, 0),
offsetof(struct jr3_t, channel[devpriv->n_channels]));
if (!devpriv->iobase)
return -ENOMEM;

result = alloc_subdevices(dev, devpriv->n_channels);
if (result < 0)
goto out;
Expand Down

0 comments on commit fa5c5f4

Please sign in to comment.