poc: don't access *data when insn->n == 0
authorIan Abbott <abbotti@mev.co.uk>
Thu, 15 Dec 2011 18:37:34 +0000 (18:37 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Thu, 15 Dec 2011 18:37:34 +0000 (18:37 +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/poc.c

index 4aa14762dd0446765996e8ff3a997d693a57305f..3a22732eef7a18d3db67783edfb952cff1aac032 100644 (file)
@@ -175,6 +175,9 @@ static int readback_insn(comedi_device * dev, comedi_subdevice * s,
 {
        int chan;
 
+       if (insn->n == 0)
+               return 0;
+
        chan = CR_CHAN(insn->chanspec);
        data[0] = ((lsampl_t *) dev->private)[chan];
 
@@ -192,6 +195,9 @@ static int dac02_ao_winsn(comedi_device * dev, comedi_subdevice * s,
        int chan;
        int output;
 
+       if (insn->n == 0)
+               return 0;
+
        chan = CR_CHAN(insn->chanspec);
        ((lsampl_t *) dev->private)[chan] = data[0];
        output = data[0];