From e82aa7b16593508432430f49e151cb3b4d68e4a5 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 15 Dec 2011 19:29:52 +0000 Subject: [PATCH] cb_pcidas: don't access *data when insn-en == 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 --- comedi/drivers/cb_pcidas.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/comedi/drivers/cb_pcidas.c b/comedi/drivers/cb_pcidas.c index 39f48bb9..46f75629 100644 --- a/comedi/drivers/cb_pcidas.c +++ b/comedi/drivers/cb_pcidas.c @@ -873,6 +873,9 @@ static int cb_pcidas_ao_nofifo_winsn(comedi_device * dev, comedi_subdevice * s, int channel; unsigned long flags; + if (insn->n == 0) + return 0; + // set channel and range channel = CR_CHAN(insn->chanspec); comedi_spin_lock_irqsave(&dev->spinlock, flags); @@ -898,6 +901,9 @@ static int cb_pcidas_ao_fifo_winsn(comedi_device * dev, comedi_subdevice * s, int channel; unsigned long flags; + if (insn->n == 0) + return 0; + // clear dac fifo outw(0, devpriv->ao_registers + DACFIFOCLR); @@ -926,6 +932,9 @@ static int cb_pcidas_ao_fifo_winsn(comedi_device * dev, comedi_subdevice * s, static int cb_pcidas_ao_readback_insn(comedi_device * dev, comedi_subdevice * s, comedi_insn * insn, lsampl_t * data) { + if (insn->n == 0) + return 0; + data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)]; return 1; @@ -937,6 +946,9 @@ static int eeprom_read_insn(comedi_device * dev, comedi_subdevice * s, uint8_t nvram_data; int retval; + if (insn->n == 0) + return 0; + retval = nvram_read(dev, CR_CHAN(insn->chanspec), &nvram_data); if (retval < 0) return retval; @@ -951,12 +963,18 @@ static int caldac_write_insn(comedi_device * dev, comedi_subdevice * s, { const unsigned int channel = CR_CHAN(insn->chanspec); + if (insn->n == 0) + return 0; + return caldac_8800_write(dev, channel, data[0]); } static int caldac_read_insn(comedi_device * dev, comedi_subdevice * s, comedi_insn * insn, lsampl_t * data) { + if (insn->n == 0) + return 0; + data[0] = devpriv->caldac_value[CR_CHAN(insn->chanspec)]; return 1; @@ -986,12 +1004,18 @@ static int dac08_write(comedi_device * dev, lsampl_t value) static int dac08_write_insn(comedi_device * dev, comedi_subdevice * s, comedi_insn * insn, lsampl_t * data) { + if (insn->n == 0) + return 0; + return dac08_write(dev, data[0]); } static int dac08_read_insn(comedi_device * dev, comedi_subdevice * s, comedi_insn * insn, lsampl_t * data) { + if (insn->n == 0) + return 0; + data[0] = devpriv->dac08_value; return 1; @@ -1025,6 +1049,9 @@ static int trimpot_write_insn(comedi_device * dev, comedi_subdevice * s, { unsigned int channel = CR_CHAN(insn->chanspec); + if (insn->n == 0) + return 0; + return cb_pcidas_trimpot_write(dev, channel, data[0]); } @@ -1033,6 +1060,9 @@ static int trimpot_read_insn(comedi_device * dev, comedi_subdevice * s, { unsigned int channel = CR_CHAN(insn->chanspec); + if (insn->n == 0) + return 0; + data[0] = devpriv->trimpot_value[channel]; return 1; -- 2.26.2