[PATCH] cdc-acm: fix consecutive writes while device is suspended

From: Oliver Neukum
Date: Tue Apr 08 2014 - 06:17:39 EST


CDC-ACM needs to handle one attempt to write to a suspended
device because we told the tty layer that there is room.
A second attempt may and must fail or we drop data.

Signed-off-by: Oliver Neukum <oneukum@xxxxxxx>
CC: stable@xxxxxxxxxxxxxxx
---
drivers/usb/class/cdc-acm.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 900f7ff..7ad3105 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -646,10 +646,12 @@ static int acm_tty_write(struct tty_struct *tty,

usb_autopm_get_interface_async(acm->control);
if (acm->susp_count) {
- if (!acm->delayed_wb)
+ if (!acm->delayed_wb) {
acm->delayed_wb = wb;
- else
+ } else {
usb_autopm_put_interface_async(acm->control);
+ count = 0;
+ }
spin_unlock_irqrestore(&acm->write_lock, flags);
return count; /* A white lie */
}
--
1.8.4.5



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/