From 14816b16fa0adac24f82492f18fa62c55acabbbe Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 8 Feb 2017 18:53:08 +0100 Subject: USB: serial: console: fix uninitialised spinlock Since commit 4a510969374a ("tty: Make tty_files_lock per-tty") a new tty_struct spin lock is taken in the tty release path, but the USB-serial-console hack was never updated hence leaving the lock of its "fake" tty uninitialised. This was eventually detected by lockdep. Make sure to initialise the new lock also for the fake tty to address this regression. Yes, this code is a mess, but cleaning it up is left for another day. Fixes: 4a510969374a ("tty: Make tty_files_lock per-tty") Cc: stable # 4.6 Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/console.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb/serial/console.c') diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index 8967715fe6fc..b6f1adefb758 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c @@ -143,6 +143,7 @@ static int usb_console_setup(struct console *co, char *options) tty->driver = usb_serial_tty_driver; tty->index = co->index; init_ldsem(&tty->ldisc_sem); + spin_lock_init(&tty->files_lock); INIT_LIST_HEAD(&tty->tty_files); kref_get(&tty->driver->kref); __module_get(tty->driver->owner); -- cgit v1.2.3 From 0e517c93dc027e49d4523fe32631606b12f0752d Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Wed, 8 Feb 2017 18:53:09 +0100 Subject: USB: serial: console: clean up sanity checks Drop two redundant NULL checks from usb_serial_console_disconnect(). The usb_serial_console_disconnect function is called from the USB-serial-device disconnect callback when a device is going away. Hence there is no need to check for the serial-device pointer being NULL. The serial-device port pointers are stored in an array that is a member of the serial struct so the address of the first member of the array (which the array name decays to) is never NULL either. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold --- drivers/usb/serial/console.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/usb/serial/console.c') diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c index b6f1adefb758..fdf89800ebc3 100644 --- a/drivers/usb/serial/console.c +++ b/drivers/usb/serial/console.c @@ -265,8 +265,7 @@ static struct console usbcons = { void usb_serial_console_disconnect(struct usb_serial *serial) { - if (serial && serial->port && serial->port[0] - && serial->port[0] == usbcons_info.port) { + if (serial->port[0] == usbcons_info.port) { usb_serial_console_exit(); usb_serial_put(serial); } -- cgit v1.2.3