Skip to content

Commit

Permalink
cdc-acm: fix crash if flushed with nothing buffered
Browse files Browse the repository at this point in the history
Under some circumstances acm_tty_flush_chars() is called
with no buffer to flush. We simply need to do nothing.

Signed-off-by: Oliver Neukum <[email protected]>
Reported-by: Torsten Hilbrich <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
oneukum authored and gregkh committed Apr 13, 2016
1 parent bf16200 commit 2a14759
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/usb/class/cdc-acm.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,11 +744,15 @@ static void acm_tty_flush_chars(struct tty_struct *tty)
int err;
unsigned long flags;

if (!cur) /* nothing to do */
return;

acm->putbuffer = NULL;
err = usb_autopm_get_interface_async(acm->control);
spin_lock_irqsave(&acm->write_lock, flags);
if (err < 0) {
cur->use = 0;
acm->putbuffer = cur;
goto out;
}

Expand Down

0 comments on commit 2a14759

Please sign in to comment.