Skip to content

Commit

Permalink
USB: serial: console: clean up sanity checks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johan Hovold committed Feb 8, 2017
1 parent 14816b1 commit 0e517c9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/usb/serial/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 0e517c9

Please sign in to comment.