Re: [PATCH v3 30/31] staging: comedi: ni_pcidio: request_irq() before setting up subdevices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2013-12-06 16:57, H Hartley Sweeten wrote:
Do the request_irq() before setting up the subdevices. Only hook up
the command support of the irq was sucessfully requested.

Note that, because of the IRQF_SHARED flag, nidio_interrupt() _may_
be called before the device is ready and the subdevices are setup.
This condition is handled by the (!dev->attached) sanity check. The
'dev->read_subdev' pointer might not be valid at this point so there
is an extra check to get the pointer to the comedi_async buffer.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
v3: fix a possible dereference of 's' in nido_interrupt()

  drivers/staging/comedi/drivers/ni_pcidio.c | 40 +++++++++++++++---------------
  1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c
index 30c46a3..8f1b64d 100644
--- a/drivers/staging/comedi/drivers/ni_pcidio.c
+++ b/drivers/staging/comedi/drivers/ni_pcidio.c
@@ -385,7 +385,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
  	struct comedi_device *dev = d;
  	struct nidio96_private *devpriv = dev->private;
  	struct comedi_subdevice *s = dev->read_subdev;
-	struct comedi_async *async = s->async;
+	struct comedi_async *async = s ? s->async : NULL;
  	struct mite_struct *mite = devpriv->mite;

It should work, but wouldn't it be better to leave `async` unassigned until after the `dev->attached` check?

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux