From c3efe3c77a6f68d19735474320fe369ef9054de1 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Thu, 22 Apr 2004 21:58:33 +0000 Subject: [PATCH] crashes on pci-das6402/16 attach seem to be due to interrupt handler 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 | 4 ++-- comedi/drivers/cb_pcidas64.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/comedi/drivers.c b/comedi/drivers.c index d0696911..66f16ec0 100644 --- a/comedi/drivers.c +++ b/comedi/drivers.c @@ -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); diff --git a/comedi/drivers/cb_pcidas64.c b/comedi/drivers/cb_pcidas64.c index c1c752d6..8a39e538 100644 --- a/comedi/drivers/cb_pcidas64.c +++ b/comedi/drivers/cb_pcidas64.c @@ -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); -- 2.26.2