USB: serial: console: clean up sanity checks 63/292563/1
authorJohan Hovold <johan@kernel.org>
Wed, 8 Feb 2017 17:53:09 +0000 (18:53 +0100)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 8 May 2023 09:35:46 +0000 (18:35 +0900)
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 <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
[sw0312.kim: backport upstream commit 0e517c93dc02 to resolve gcc-12 build issue]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: Ia32e9685c652ee25704be755fa5788bf93b16a82

drivers/usb/serial/console.c

index 76062ce..635a137 100644 (file)
@@ -266,8 +266,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);
        }