crashes on pci-das6402/16 attach seem to be due to interrupt handler
authorFrank Mori Hess <fmhess@speakeasy.net>
Thu, 22 Apr 2004 21:58:33 +0000 (21:58 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Thu, 22 Apr 2004 21:58:33 +0000 (21:58 +0000)
running before postconfig() in drivers.c has finished initializing
everything.  So I added check for dev->attached in handler, and
put a barrier() before dev->attached is set in drivers.c.

comedi/drivers.c
comedi/drivers/cb_pcidas64.c

index d0696911ce112e84b517c32647c79f48a1dea6a9..66f16ec06559551eef03c766305ac80e343353c3 100644 (file)
@@ -182,7 +182,7 @@ attached:
                printk("BUG: dev->board_name=<%p>\n",dev->board_name);
                dev->board_name="BUG";
        }
-
+       barrier();
        dev->attached=1;
 
        return 0;
@@ -259,7 +259,7 @@ static int postconfig(comedi_device *dev)
                        continue;
 
                if(s->len_chanlist==0)
-                       s->len_chanlist=1; 
+                       s->len_chanlist=1;
 
                if(s->do_cmd){
                        async = kmalloc(sizeof(comedi_async), GFP_KERNEL);
index c1c752d67481496b516397e8cf191857a9e6a451..8a39e5389686364ac044e3864b9894b63efd3283 100644 (file)
@@ -1707,10 +1707,6 @@ static int attach(comedi_device *dev, comedi_devconfig *it)
        {
                return retval;
        }
-       /* make sure everything is written out to memory before there is a possibility
-        * of the interrupt handler executing (trying to fix mysterious pci-das6402/16
-        * crash during attach) */
-       mb();
        // get irq
        if(comedi_request_irq(pcidev->irq, handle_interrupt, SA_SHIRQ, "cb_pcidas64", dev ))
        {
@@ -3008,6 +3004,14 @@ static irqreturn_t handle_interrupt(int irq, void *d, struct pt_regs *regs)
        DEBUG_PRINT("cb_pcidas64: hw status 0x%x ", status);
        DEBUG_PRINT("plx status 0x%x\n", plx_status);
 
+       /* an interrupt before all the postconfig stuff gets done could
+        * cause a NULL dereference if we continue through the
+        * interrupt handler */
+       if(dev->attached == 0)
+       {
+               DEBUG_PRINT("cb_pcidas64: premature interrupt, ignoring", status);
+               return;
+       }
        handle_ai_interrupt(dev, status, plx_status);
        handle_ao_interrupt(dev, status, plx_status);