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

index 379bd84f397d4868ca84da00c04a542106afe595..04ee679be64a385117fd15fd97783031b3a7bd50 100644 (file)
@@ -311,6 +311,9 @@ static int pci20006_insn_read(comedi_device * dev, comedi_subdevice * s,
 {
        pci20xxx_subdev_private *sdp = s->private;
 
+       if (insn->n == 0)
+               return 0;
+
        data[0] = sdp->pci20006.last_data[CR_CHAN(insn->chanspec)];
 
        return 1;
@@ -323,6 +326,9 @@ static int pci20006_insn_write(comedi_device * dev, comedi_subdevice * s,
        int hi, lo;
        unsigned int boarddata;
 
+       if (insn->n == 0)
+               return 0;
+
        sdp->pci20006.last_data[CR_CHAN(insn->chanspec)] = data[0];
        boarddata = (((unsigned int)data[0] + 0x8000) & 0xffff);        /* comedi-data -> board-data */
        lo = (boarddata & 0xff);