From: Ian Abbott Date: Thu, 15 Dec 2011 19:16:04 +0000 (+0000) Subject: adv_pci1710: don't access *data when insn->n == 0 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=79ac6939202294a1707c49d386277c57568324c6;p=comedi.git adv_pci1710: 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. Also, the INSN_WRITE handlers for AO subdevices were incorrectly storing the data value past the end of the data array for read-back, instead of the last data value (when insn->n > 0). Signed-off-by: Ian Abbott --- diff --git a/comedi/drivers/adv_pci1710.c b/comedi/drivers/adv_pci1710.c index ac0282bf..7507653e 100644 --- a/comedi/drivers/adv_pci1710.c +++ b/comedi/drivers/adv_pci1710.c @@ -412,7 +412,8 @@ static int pci171x_insn_write_ao(comedi_device * dev, comedi_subdevice * s, for (n = 0; n < insn->n; n++) outw(data[n], dev->iobase + ofs); - devpriv->ao_data[chan] = data[n]; + if (n > 0) + devpriv->ao_data[chan] = data[n - 1]; return n; @@ -566,7 +567,8 @@ static int pci1720_insn_write_ao(comedi_device * dev, comedi_subdevice * s, outb(0, dev->iobase + PCI1720_SYNCOUT); // update outputs } - devpriv->ao_data[chan] = data[n]; + if (n > 0) + devpriv->ao_data[chan] = data[n - 1]; return n; }