Commit a553add0 authored by Randy Dunlap's avatar Randy Dunlap Committed by Greg Kroah-Hartman
Browse files

serial: uartlite: fix exit path null pointer



Call uart_unregister_driver() conditionally instead of
unconditionally, only if it has been previously registered.

This uses driver.state, just as the sh-sci.c driver does.

Fixes this null pointer dereference in tty_unregister_driver(),
since the 'driver' argument is null:

  general protection fault: 0000 [#1] PREEMPT SMP KASAN PTI
  RIP: 0010:tty_unregister_driver+0x25/0x1d0

Fixes: 238b8721 ("[PATCH] serial uartlite driver")
Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
Cc: stable <stable@vger.kernel.org>
Cc: Peter Korsgaard <jacmet@sunsite.dk>
Link: https://lore.kernel.org/r/9c8e6581-6fcc-a595-0897-4d90f5d710df@infradead.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 90500797
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -897,6 +897,7 @@ static int __init ulite_init(void)
static void __exit ulite_exit(void)
static void __exit ulite_exit(void)
{
{
	platform_driver_unregister(&ulite_platform_driver);
	platform_driver_unregister(&ulite_platform_driver);
	if (ulite_uart_driver.state)
		uart_unregister_driver(&ulite_uart_driver);
		uart_unregister_driver(&ulite_uart_driver);
}
}