]> git.hungrycats.org Git - linux/commitdiff
USB: serial: console: fix use-after-free after failed setup
authorJohan Hovold <johan@kernel.org>
Wed, 4 Oct 2017 09:01:13 +0000 (11:01 +0200)
committerSasha Levin <alexander.levin@verizon.com>
Mon, 6 Nov 2017 04:54:27 +0000 (23:54 -0500)
[ Upstream commit 299d7572e46f98534033a9e65973f13ad1ce9047 ]

Make sure to reset the USB-console port pointer when console setup fails
in order to avoid having the struct usb_serial be prematurely freed by
the console code when the device is later disconnected.

Fixes: 73e487fdb75f ("[PATCH] USB console: fix disconnection issues")
Cc: stable <stable@vger.kernel.org> # 2.6.18
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
drivers/usb/serial/console.c

index 3806e7014199d13c892f32e8a03c1b37e286bddb..2938153fe7b1dc86c8140ca48327e40efb63d670 100644 (file)
@@ -189,6 +189,7 @@ static int usb_console_setup(struct console *co, char *options)
        tty_kref_put(tty);
  reset_open_count:
        port->port.count = 0;
+       info->port = NULL;
        usb_autopm_put_interface(serial->interface);
  error_get_interface:
        usb_serial_put(serial);