From 29a1568769832fa722fd074be60a9563a8b0b678 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 15 Dec 2011 19:55:53 +0000 Subject: [PATCH] ni_labpc: 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 --- comedi/drivers/ni_labpc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/comedi/drivers/ni_labpc.c b/comedi/drivers/ni_labpc.c index 93dab429..94764f23 100644 --- a/comedi/drivers/ni_labpc.c +++ b/comedi/drivers/ni_labpc.c @@ -1594,6 +1594,9 @@ static int labpc_ao_winsn(comedi_device * dev, comedi_subdevice * s, unsigned long flags; int lsb, msb; + if (insn->n == 0) + return 0; + channel = CR_CHAN(insn->chanspec); // turn off pacing of analog output channel @@ -1631,6 +1634,9 @@ static int labpc_ao_winsn(comedi_device * dev, comedi_subdevice * s, static int labpc_ao_rinsn(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; @@ -1639,6 +1645,9 @@ static int labpc_ao_rinsn(comedi_device * dev, comedi_subdevice * s, static int labpc_calib_read_insn(comedi_device * dev, comedi_subdevice * s, comedi_insn * insn, lsampl_t * data) { + if (insn->n == 0) + return 0; + data[0] = devpriv->caldac[CR_CHAN(insn->chanspec)]; return 1; @@ -1649,6 +1658,9 @@ static int labpc_calib_write_insn(comedi_device * dev, comedi_subdevice * s, { int channel = CR_CHAN(insn->chanspec); + if (insn->n == 0) + return 0; + write_caldac(dev, channel, data[0]); return 1; } @@ -1656,6 +1668,9 @@ static int labpc_calib_write_insn(comedi_device * dev, comedi_subdevice * s, static int labpc_eeprom_read_insn(comedi_device * dev, comedi_subdevice * s, comedi_insn * insn, lsampl_t * data) { + if (insn->n == 0) + return 0; + data[0] = devpriv->eeprom_data[CR_CHAN(insn->chanspec)]; return 1; @@ -1673,6 +1688,9 @@ static int labpc_eeprom_write_insn(comedi_device * dev, comedi_subdevice * s, return -EINVAL; } + if (insn->n == 0) + return 0; + ret = labpc_eeprom_write(dev, channel, data[0]); if (ret < 0) return ret; -- 2.26.2