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

Ian Abbott abbotti at mev.co.uk
Fri Dec 6 17:18:44 UTC 2013


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 at visionengravers.com>
> Cc: Ian Abbott <abbotti at mev.co.uk>
> Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
> ---
> 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 at mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-


More information about the devel mailing list