serial: core: fix potential NULL pointer dereference

The commit 761ed4a94582 ("tty: serial_core: convert uart_close to use
tty_port_close") refactored uart_close() to use tty_port_close().  At the same
time it introduced a potential NULL pointer dereference. Rearrange the code to
avoid kernel crash.

Fixes: 761ed4a94582 ("tty: serial_core: convert uart_close to use tty_port_close")
Cc: Rob Herring <robh@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 file changed