From: Ian Abbott Date: Mon, 14 Jan 2008 12:26:16 +0000 (+0000) Subject: Corrected test for INSN_WRITE data value exceeding maxdata. It failed on X-Git-Tag: v0_7_76~9 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3b6df96e0bcf2c7739bc760d50df9d355a4289bd;p=comedi.git Corrected test for INSN_WRITE data value exceeding maxdata. It failed on subdevices that used per-channel maxdata values (maxdata_list). --- diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index f437b431..56123a04 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -788,6 +788,8 @@ static int parse_insn(comedi_device * dev, comedi_insn * insn, lsampl_t * data, } } else { /* a subdevice instruction */ + lsampl_t maxdata; + if (insn->subdev >= dev->n_subdevices) { DPRINTK("subdevice %d out of range\n", insn->subdev); ret = -EINVAL; @@ -825,9 +827,15 @@ static int parse_insn(comedi_device * dev, comedi_insn * insn, lsampl_t * data, ret = s->insn_read(dev, s, insn, data); break; case INSN_WRITE: + maxdata = s->maxdata_list + ? s->maxdata_list[CR_CHAN(insn->chanspec)] + : s->maxdata; for (i = 0; i < insn->n; ++i) { - if (data[i] > s->maxdata) + if (data[i] > maxdata) { ret = -EINVAL; + DPRINTK("bad data value(s)\n"); + break; + } } if (ret == 0) ret = s->insn_write(dev, s, insn, data);