All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] USB: serial: console: Move mutex_unlock() before usb_serial_put()
@ 2022-09-19 10:48 Liang He
  2022-09-19 13:29 ` Johan Hovold
  0 siblings, 1 reply; 2+ messages in thread
From: Liang He @ 2022-09-19 10:48 UTC (permalink / raw)
  To: johan, gregkh, linux-usb; +Cc: windhl

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")
Signed-off-by: Liang He <windhl@126.com>
---
 drivers/usb/serial/console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index b97aa40ca4d1..da19a5fa414f 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -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;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] USB: serial: console: Move mutex_unlock() before usb_serial_put()
  2022-09-19 10:48 [PATCH v2] USB: serial: console: Move mutex_unlock() before usb_serial_put() Liang He
@ 2022-09-19 13:29 ` Johan Hovold
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2022-09-19 13:29 UTC (permalink / raw)
  To: Liang He; +Cc: gregkh, linux-usb

On Mon, Sep 19, 2022 at 06:48:24PM +0800, Liang He wrote:
> 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")
> Signed-off-by: Liang He <windhl@126.com>

Applied, thanks.

Johan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-19 13:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-19 10:48 [PATCH v2] USB: serial: console: Move mutex_unlock() before usb_serial_put() Liang He
2022-09-19 13:29 ` Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.