From: Ian Abbott Date: Wed, 3 Oct 2012 15:25:17 +0000 (+0100) Subject: staging: comedi: amplc_pc236: fix invalid register access during detach X-Git-Tag: v3.6.5~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec7fe3d6e91ff29ee3000e35f13f5eb3df2eca30;p=thirdparty%2Fkernel%2Fstable.git staging: comedi: amplc_pc236: fix invalid register access during detach 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index f50287903038b..cfbb83b9526a1 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -577,10 +577,9 @@ static int __devinit pc236_attach_pci(struct comedi_device *dev, static void pc236_detach(struct comedi_device *dev) { - struct pc236_private *devpriv = dev->private; struct pci_dev *pcidev = comedi_to_pci_dev(dev); - if (devpriv) + if (dev->iobase) pc236_intr_disable(dev); if (dev->irq) free_irq(dev->irq, dev);