patch "USB: serial: ti_usb_3410_5052: fix port-close races" added to usb-linus
Subsystems (3)
This is a note to let you know that I've just added the patch titled
USB: serial: ti_usb_3410_5052: fix port-close races
to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From 6f1d1dc8d540a9aa6e39b9cb86d3a67bbc1c8d8d Mon Sep 17 00:00:00 2001
From: Johan Hovold <[email protected]>
Date: Fri, 11 Oct 2019 11:57:35 +0200
Subject: USB: serial: ti_usb_3410_5052: fix port-close races
Fix races between closing a port and opening or closing another port on the same device which could lead to a failure to start or stop the shared interrupt URB. The latter could potentially cause a use-after-free or worse in the completion handler on driver unbind.
--- drivers/usb/serial/ti_usb_3410_5052.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/usb/serial/ti_usb_3410_5052.c +3 -7
@@ -776,7 +776,6 @@ static void ti_close(struct usb_serial_port *port)struct ti_port *tport;int port_number;int status; -int do_unlock;unsigned long flags; tdev =usb_get_serial_data (port->serial);
@@ -800,16 +799,13 @@ static void ti_close(struct usb_serial_port *port)"%s - cannot send close port command, %d\n" , __func__, status); -/* if mutex_lock is interrupted, continue anyway */ - do_unlock = !mutex_lock_interruptible (&tdev->td_open_close_lock); +mutex_lock (&tdev->td_open_close_lock); --tport->tp_tdev->td_open_port_count; -if (tport->tp_tdev->td_open_port_count <=0 ) { +if (tport->tp_tdev->td_open_port_count ==0 ) {/* last port is closed, shut down interrupt urb */ usb_kill_urb (port->serial->port[0 ]->interrupt_in_urb); - tport->tp_tdev->td_open_port_count =0 ; } -if (do_unlock) -mutex_unlock (&tdev->td_open_close_lock); +mutex_unlock (&tdev->td_open_close_lock); }
Signature · 1 line
2.23.0