amplc_dio200: don't access *data when insn->n == 0
authorIan Abbott <abbotti@mev.co.uk>
Thu, 15 Dec 2011 20:56:11 +0000 (20:56 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Thu, 15 Dec 2011 20:56:11 +0000 (20:56 +0000)
Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the
'data' pointer will be NULL when insn->n == 0.  Do not access *data
in this case.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
comedi/drivers/amplc_dio200.c

index 8f54b264abf44dc31f410290e07d1f0ada6b1e9e..fc960ef5962994af560226bcac064c74fc07d5c5 100644 (file)
@@ -1041,6 +1041,9 @@ dio200_subdev_8254_read(comedi_device * dev, comedi_subdevice * s,
        int chan = CR_CHAN(insn->chanspec);
        unsigned long flags;
 
+       if (insn->n == 0)
+               return 0;
+
        comedi_spin_lock_irqsave(&subpriv->spinlock, flags);
        data[0] = i8254_read(subpriv->iobase, 0, chan);
        comedi_spin_unlock_irqrestore(&subpriv->spinlock, flags);
@@ -1059,6 +1062,9 @@ dio200_subdev_8254_write(comedi_device * dev, comedi_subdevice * s,
        int chan = CR_CHAN(insn->chanspec);
        unsigned long flags;
 
+       if (insn->n == 0)
+               return 0;
+
        comedi_spin_lock_irqsave(&subpriv->spinlock, flags);
        i8254_write(subpriv->iobase, 0, chan, data[0]);
        comedi_spin_unlock_irqrestore(&subpriv->spinlock, flags);