Hi,

Here's a small patch to the acm driver that fixes a potential buffer
overrun problem that can occur.  It is against 2.4.5-pre2.

thanks,

greg k-h
diff -Nru a/drivers/usb/acm.c b/drivers/usb/acm.c
--- a/drivers/usb/acm.c Tue May 15 22:37:41 2001
+++ b/drivers/usb/acm.c Tue May 15 22:37:41 2001
@@ -233,8 +240,14 @@
                dbg("nonzero read bulk status received: %d", urb->status);
 
        if (!urb->status & !acm->throttle)  {
-               for (i = 0; i < urb->actual_length && !acm->throttle; i++)
+               for (i = 0; i < urb->actual_length && !acm->throttle; i++) {
+                       /* if we insert more than TTY_FLIPBUF_SIZE characters,
+                        * we drop them. */
+                       if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+                               tty_flip_buffer_push(tty);
+                       }
                        tty_insert_flip_char(tty, data[i], 0);
+               }
                tty_flip_buffer_push(tty);
        }
 
@@ -304,6 +317,10 @@
 
        acm_set_control(acm, acm->ctrlout = ACM_CTRL_DTR | ACM_CTRL_RTS);
 
+       /* force low_latency on so that our tty_push actually forces the data through, 
+          otherwise it is scheduled, and with high data rates data can get lost. */
+       tty->low_latency = 1;
+
        return 0;
 }
 

Reply via email to