From: Ian Abbott Date: Thu, 15 Dec 2011 20:51:45 +0000 (+0000) Subject: cb_pcidas64: don't access *data when insn->n == 0 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=19d93bf49e2e9df212a1bd09b190d8f7b9694265;p=comedi.git cb_pcidas64: don't access *data when insn->n == 0 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 --- diff --git a/comedi/drivers/cb_pcidas64.c b/comedi/drivers/cb_pcidas64.c index ead9f11c..3cb2e4b3 100644 --- a/comedi/drivers/cb_pcidas64.c +++ b/comedi/drivers/cb_pcidas64.c @@ -3200,6 +3200,9 @@ static int ao_winsn(comedi_device * dev, comedi_subdevice * s, int chan = CR_CHAN(insn->chanspec); int range = CR_RANGE(insn->chanspec); + if (insn->n == 0) + return 0; + // do some initializing writew(0, priv(dev)->main_iobase + DAC_CONTROL0_REG); @@ -3227,6 +3230,9 @@ static int ao_winsn(comedi_device * dev, comedi_subdevice * s, static int ao_readback_insn(comedi_device * dev, comedi_subdevice * s, comedi_insn * insn, lsampl_t * data) { + if (insn->n == 0) + return 0; + data[0] = priv(dev)->ao_value[CR_CHAN(insn->chanspec)]; return 1; @@ -3699,6 +3705,9 @@ static int calib_write_insn(comedi_device * dev, comedi_subdevice * s, { int channel = CR_CHAN(insn->chanspec); + if (insn->n == 0) + return 0; + /* return immediately if setting hasn't changed, since * programming these things is slow */ if (priv(dev)->caldac_state[channel] == data[0]) @@ -3714,6 +3723,9 @@ static int calib_read_insn(comedi_device * dev, comedi_subdevice * s, { unsigned int channel = CR_CHAN(insn->chanspec); + if (insn->n == 0) + return 0; + data[0] = priv(dev)->caldac_state[channel]; return 1; @@ -3755,6 +3767,9 @@ static int ad8402_write_insn(comedi_device * dev, comedi_subdevice * s, { int channel = CR_CHAN(insn->chanspec); + if (insn->n == 0) + return 0; + /* return immediately if setting hasn't changed, since * programming these things is slow */ if (priv(dev)->ad8402_state[channel] == data[0]) @@ -3772,6 +3787,9 @@ static int ad8402_read_insn(comedi_device * dev, comedi_subdevice * s, { unsigned int channel = CR_CHAN(insn->chanspec); + if (insn->n == 0) + return 0; + data[0] = priv(dev)->ad8402_state[channel]; return 1; @@ -3842,6 +3860,9 @@ static uint16_t read_eeprom(comedi_device * dev, uint8_t address) static int eeprom_read_insn(comedi_device * dev, comedi_subdevice * s, comedi_insn * insn, lsampl_t * data) { + if (insn->n == 0) + return 0; + data[0] = read_eeprom(dev, CR_CHAN(insn->chanspec)); return 1;