Commit efe8d60a authored by Bernd Porr's avatar Bernd Porr Committed by Greg Kroah-Hartman

Staging: comedi: usbdux: buffer overflow error handling

These changes guarantee that the URBs are not resubmitted in case of a
comedi buffer overflow.  Otherwise this runs in the background even when
the userspace program has terminated.

From: Bernd Porr <BerndPorr@f2s.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 0b8f754a
...@@ -509,15 +509,20 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb) ...@@ -509,15 +509,20 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb)
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
/* transfer data */ /* transfer data */
if (CR_RANGE(s->async->cmd.chanlist[i]) <= 1) { if (CR_RANGE(s->async->cmd.chanlist[i]) <= 1) {
comedi_buf_put err = comedi_buf_put
(s->async, (s->async,
le16_to_cpu(this_usbduxsub-> le16_to_cpu(this_usbduxsub->
inBuffer[i]) ^ 0x800); inBuffer[i]) ^ 0x800);
} else { } else {
comedi_buf_put err = comedi_buf_put
(s->async, (s->async,
le16_to_cpu(this_usbduxsub->inBuffer[i])); le16_to_cpu(this_usbduxsub->inBuffer[i]));
} }
if (unlikely(err == 0)) {
/* buffer overflow */
usbdux_ai_stop(this_usbduxsub, 0);
return;
}
} }
/* tell comedi that data is there */ /* tell comedi that data is there */
comedi_event(this_usbduxsub->comedidev, s); comedi_event(this_usbduxsub->comedidev, s);
......
...@@ -406,7 +406,7 @@ static void usbduxfastsub_ai_Irq(struct urb *urb) ...@@ -406,7 +406,7 @@ static void usbduxfastsub_ai_Irq(struct urb *urb)
udfs->ai_sample_count udfs->ai_sample_count
* sizeof(uint16_t)); * sizeof(uint16_t));
usbduxfast_ai_stop(udfs, 0); usbduxfast_ai_stop(udfs, 0);
/* say comedi that the acquistion is over */ /* tell comedi that the acquistion is over */
s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_EOA;
comedi_event(udfs->comedidev, s); comedi_event(udfs->comedidev, s);
return; return;
...@@ -414,8 +414,13 @@ static void usbduxfastsub_ai_Irq(struct urb *urb) ...@@ -414,8 +414,13 @@ static void usbduxfastsub_ai_Irq(struct urb *urb)
udfs->ai_sample_count -= n; udfs->ai_sample_count -= n;
} }
/* write the full buffer to comedi */ /* write the full buffer to comedi */
cfc_write_array_to_buffer(s, urb->transfer_buffer, err = cfc_write_array_to_buffer(s, urb->transfer_buffer,
urb->actual_length); urb->actual_length);
if (unlikely(err == 0)) {
/* buffer overflow */
usbduxfast_ai_stop(udfs, 0);
return;
}
/* tell comedi that data is there */ /* tell comedi that data is there */
comedi_event(udfs->comedidev, s); comedi_event(udfs->comedidev, s);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment