[PATCH 2/2] tty: serial: samsung: Fix potential NULL dereference on removal
Guangshuo Li
liguangshuo at mail.sdu.edu.cn
Mon Nov 2 16:45:47 PST 2026
Removing one port unregisters the shared UART driver and clears its
state even when other ports remain registered. Removing another port
then dereferences the cleared state.
Keep the UART driver registered until all platform devices are removed
at module exit. Retain registration on first probe.
This issue was found by our static analysis tool under development.
Fixes: 6f134c3c7703 ("serial: samsung: Move uart_register_driver call to device probe")
Signed-off-by: Guangshuo Li <liguangshuo at mail.sdu.edu.cn>
---
Build-tested the affected object with arm64 defconfig and LLVM
(W=1). No hardware or fault-injection testing was performed.
drivers/tty/serial/samsung_tty.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index 640f85e2d636..9768effbd39f 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -2058,7 +2058,6 @@ static void s3c24xx_serial_remove(struct platform_device *dev)
if (port)
uart_remove_one_port(&s3c24xx_uart_drv, port);
- uart_unregister_driver(&s3c24xx_uart_drv);
}
/* UART power management code */
@@ -2684,6 +2683,8 @@ static int __init samsung_serial_init(void)
static void __exit samsung_serial_exit(void)
{
platform_driver_unregister(&samsung_serial_driver);
+ if (s3c24xx_uart_drv.state)
+ uart_unregister_driver(&s3c24xx_uart_drv);
s3c24xx_serial_unregister_console();
}
--
2.43.0
More information about the linux-arm-kernel
mailing list