Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aaeb61a9 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman
Browse files

staging: comedi: amplc_pc236: fix invalid register access during detach



`pc236_detach()` is called by the comedi core if it attempted to attach
a device and failed.  `pc236_detach()` calls `pc236_intr_disable()` if
the comedi device private data pointer (`devpriv`) is non-null.  This
test is insufficient as `pc236_intr_disable()` accesses hardware
registers and the attach routine may have failed before it has saved
their I/O base addresses.

Fix it by checking `dev->iobase` is non-zero before calling
`pc236_intr_disable()` as that means the I/O base addresses have been
saved and the hardware registers can be accessed.  It also implies the
comedi device private data pointer is valid, so there is no need to
check it.

Cc: <stable@vger.kernel.org> # 3.5.x, 3.6.x
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dfb2540e
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -573,9 +573,8 @@ static int __devinit pc236_attach_pci(struct comedi_device *dev,
static void pc236_detach(struct comedi_device *dev)
static void pc236_detach(struct comedi_device *dev)
{
{
	const struct pc236_board *thisboard = comedi_board(dev);
	const struct pc236_board *thisboard = comedi_board(dev);
	struct pc236_private *devpriv = dev->private;


	if (devpriv)
	if (dev->iobase)
		pc236_intr_disable(dev);
		pc236_intr_disable(dev);
	if (dev->irq)
	if (dev->irq)
		free_irq(dev->irq, dev);
		free_irq(dev->irq, dev);