Skip to content

Commit

Permalink
staging: comedi: amplc_pc263: check bus type in detach routine
Browse files Browse the repository at this point in the history
When detaching the device in pc263_detach() mirror the bus type checks
performed by pc263_attach().  The existing tests are safe but rely on
dev->iobase being 0 when comedi_to_pci_dev(dev) is NULL.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Aug 16, 2012
1 parent d267694 commit 6c29227
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions drivers/staging/comedi/drivers/amplc_pc263.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,18 @@ static int __devinit pc263_attach_pci(struct comedi_device *dev,

static void pc263_detach(struct comedi_device *dev)
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
const struct pc263_board *thisboard = comedi_board(dev);

if (pcidev) {
if (dev->iobase)
comedi_pci_disable(pcidev);
pci_dev_put(pcidev);
} else {
if (is_isa_board(thisboard)) {
if (dev->iobase)
release_region(dev->iobase, PC263_IO_SIZE);
} else if (is_pci_board(thisboard)) {
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
if (pcidev) {
if (dev->iobase)
comedi_pci_disable(pcidev);
pci_dev_put(pcidev);
}
}
}

Expand Down

0 comments on commit 6c29227

Please sign in to comment.