From 3b6df96e0bcf2c7739bc760d50df9d355a4289bd Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 14 Jan 2008 12:26:16 +0000 Subject: [PATCH] Corrected test for INSN_WRITE data value exceeding maxdata. It failed on subdevices that used per-channel maxdata values (maxdata_list). --- comedi/comedi_fops.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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); -- 2.26.2