Skip to contentSkip to conversation

USB: serial: console: Move mutex_unlock() before usb_serial_put()

PATCH Applied Liang He 2 participants 2 messages Sep 19, 2022

Subsystems (2)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH v2 1/1 USB: serial: console: Move mutex_unlock() before usb_serial_put()

While in current version there is no use-after-free as USB serial core holds another reference when the console is registered, we should better unlock before dropping the reference in usb_console_setup().

Fixes 7bd032dc2793 ("USB serial: update the console driver")
---
 drivers/usb/serial/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/serial/console.c +1 -1
index b97aa40ca4d1..da19a5fa414f 100644
@@ -189,8 +189,8 @@ static int usb_console_setup(struct console *co, char *options)
 	info->port = NULL;
 	usb_autopm_put_interface(serial->interface);
  error_get_interface:
-	usb_serial_put(serial);
 	mutex_unlock(&serial->disc_mutex);
+	usb_serial_put(serial);
 	return retval;
 }
 
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 7 lines · Liang He

While in current version there is no use-after-free as USB serial core holds another reference when the console is registered, we should better unlock before dropping the reference in usb_console_setup().

Fixes 7bd032dc2793 ("USB serial: update the console driver")

Applied, thanks.

Johan