Skip to content

Commit

Permalink
staging: comedi: ni_labpc: fix common detach
Browse files Browse the repository at this point in the history
`labpc_common_detach()` calls `comedi_pci_disable()` unconditionally.
That's okay for PCI devices and harmless for ISA devices (as the
`hw_dev` member will be NULL so `comedi_to_pci_dev()` will return NULL
and `comedi_pci_disable()` checks for that), but it is disastrous for
PCMCIA devices.  Those are managed by the "ni_labpc_cs" module but it
calls this `labpc_common_detach()` and the `hw_dev` member will be
pointing to the `struct device` embedded in a `struct pcmcia_device` in
that case.  That's enough to confuse `comedi_pci_disable()` into
thinking it's a valid PCI device to be disabled.

Use the private board information (`thisboard`) to make sure it is a PCI
device before calling `comedi_pci_disable()`.

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 Mar 15, 2013
1 parent 84b44d0 commit a145928
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/staging/comedi/drivers/ni_labpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,8 @@ void labpc_common_detach(struct comedi_device *dev)
mite_unsetup(devpriv->mite);
mite_free(devpriv->mite);
}
comedi_pci_disable(dev);
if (thisboard->bustype == pci_bustype)
comedi_pci_disable(dev);
#endif
};
EXPORT_SYMBOL_GPL(labpc_common_detach);
Expand Down

0 comments on commit a145928

Please sign in to comment.