Skip to content

Commit 2a14759

Browse files
oneukumgregkh
authored andcommitted
cdc-acm: fix crash if flushed with nothing buffered
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 <ONeukum@suse.com> Reported-by: Torsten Hilbrich <torsten.hilbrich@secunet.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bf16200 commit 2a14759

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/usb/class/cdc-acm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,11 +744,15 @@ static void acm_tty_flush_chars(struct tty_struct *tty)
744744
int err;
745745
unsigned long flags;
746746

747+
if (!cur) /* nothing to do */
748+
return;
749+
747750
acm->putbuffer = NULL;
748751
err = usb_autopm_get_interface_async(acm->control);
749752
spin_lock_irqsave(&acm->write_lock, flags);
750753
if (err < 0) {
751754
cur->use = 0;
755+
acm->putbuffer = cur;
752756
goto out;
753757
}
754758

0 commit comments

Comments
 (0)