USB: serial: keyspan_pda: fix tx-unthrottle use-after-free
authorJohan Hovold <johan@kernel.org>
Sun, 25 Oct 2020 17:45:51 +0000 (18:45 +0100)
committerJohan Hovold <johan@kernel.org>
Wed, 4 Nov 2020 10:01:19 +0000 (11:01 +0100)
The driver's transmit-unthrottle work was never flushed on disconnect,
something which could lead to the driver port data being freed while the
unthrottle work is still scheduled.

Fix this by cancelling the unthrottle work when shutting down the port.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
drivers/usb/serial/keyspan_pda.c

index d91180ab5f3b6a2e969c0b0abbb42bf97d7904ec..781b6723379f6045b6855238f7453a7693b5fc2c 100644 (file)
@@ -647,8 +647,12 @@ error:
 }
 static void keyspan_pda_close(struct usb_serial_port *port)
 {
+       struct keyspan_pda_private *priv = usb_get_serial_port_data(port);
+
        usb_kill_urb(port->write_urb);
        usb_kill_urb(port->interrupt_in_urb);
+
+       cancel_work_sync(&priv->unthrottle_work);
 }