]> git.baikalelectronics.ru Git - kernel.git/commitdiff
cdc-acm: fix crash if flushed with nothing buffered
authorOliver Neukum <oneukum@suse.com>
Mon, 4 Apr 2016 12:30:53 +0000 (14:30 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Apr 2016 18:53:07 +0000 (11:53 -0700)
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>
drivers/usb/class/cdc-acm.c

index 83fd30b0577c55f33eace402617ff3a2a4b09126..a6c4a1b895bd4e5acdab56b4a5a5abf512be6244 100644 (file)
@@ -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;
        }