]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: comedi: amplc_pc236: fix invalid register access during detach
authorIan Abbott <abbotti@mev.co.uk>
Wed, 3 Oct 2012 15:25:17 +0000 (16:25 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Oct 2012 17:03:19 +0000 (10:03 -0700)
commit aaeb61a97b7159ebe30b18a422d04eeabfa8790b upstream.

`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.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/amplc_pc236.c

index 7972cadd403e921ac392857667a19609da48de1a..9a23d20938a5d10137ccbb5ed576f9df912c9666 100644 (file)
@@ -468,7 +468,7 @@ static int pc236_detach(struct comedi_device *dev)
 {
        printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
               PC236_DRIVER_NAME);
-       if (devpriv)
+       if (dev->iobase)
                pc236_intr_disable(dev);
 
        if (dev->irq)