addi_common: don't access *data when insn->n == 0
authorIan Abbott <abbotti@mev.co.uk>
Thu, 15 Dec 2011 20:24:17 +0000 (20:24 +0000)
committerIan Abbott <abbotti@mev.co.uk>
Thu, 15 Dec 2011 20:24:17 +0000 (20:24 +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.

The INSN_READ handler for the EEPROM was ignoring insn->n.

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

index 01870467877cc225af5b1a916e5ca49150b1cdd4..3495e318a453dc4bb0dfe496cc65b6c2f4b1740a 100644 (file)
@@ -3066,6 +3066,9 @@ static int i_ADDIDATA_InsnReadEeprom(comedi_device * dev, comedi_subdevice * s,
        WORD w_Address;
        w_Address = CR_CHAN(insn->chanspec);    // address to be read as 0,1,2,3...255
 
+       if (insn->n == 0)
+               return 0;
+
        w_Data = w_EepromReadWord(devpriv->i_IobaseAmcc,
                this_board->pc_EepromChip, 0x100 + (2 * w_Address));
        data[0] = w_Data;