All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] tty: serial: Keep UART driver state until ports are removed
@ 2026-11-03  0:45 Guangshuo Li
  2026-11-03  0:45 ` [PATCH 1/2] tty: serial: ip22zilog: Fix potential NULL dereference on exit Guangshuo Li
  2026-11-03  0:45 ` [PATCH 2/2] tty: serial: samsung: Fix potential NULL dereference on removal Guangshuo Li
  0 siblings, 2 replies; 5+ messages in thread
From: Guangshuo Li @ 2026-11-03  0:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Guangshuo Li, Thomas Bogendoerfer, linux-kernel, linux-serial,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Tushar Behera,
	linux-arm-kernel, linux-samsung-soc

Keep shared UART state available until all ports have been removed.
The two independent fixes cover ip22zilog module exit and Samsung
per-port removal.

Prepared with AI assistance and reviewed by the submitter. The affected
objects were build-tested with W=1; configuration details are included
with each patch. No hardware or fault-injection tests were performed.

Guangshuo Li (2):
  tty: serial: ip22zilog: Fix potential NULL dereference on exit
  tty: serial: samsung: Fix potential NULL dereference on removal

 drivers/tty/serial/ip22zilog.c   | 2 +-
 drivers/tty/serial/samsung_tty.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)


base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] tty: serial: ip22zilog: Fix potential NULL dereference on exit
  2026-11-03  0:45 [PATCH 0/2] tty: serial: Keep UART driver state until ports are removed Guangshuo Li
@ 2026-11-03  0:45 ` Guangshuo Li
  2026-11-03  0:50   ` sashiko-bot
  2026-11-03  0:45 ` [PATCH 2/2] tty: serial: samsung: Fix potential NULL dereference on removal Guangshuo Li
  1 sibling, 1 reply; 5+ messages in thread
From: Guangshuo Li @ 2026-11-03  0:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Guangshuo Li, Thomas Bogendoerfer, linux-kernel, linux-serial

uart_unregister_driver() frees and clears the shared UART state before
platform driver removal calls uart_remove_one_port(), which still needs
that state.

Remove the ports before unregistering the UART driver.

This issue was found by our static analysis tool under development.

Fixes: 3fc36ae6abd2 ("tty: serial: ip22zilog: Use platform device for probing")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
Build-tested the affected object with MIPS ip22_defconfig and LLVM
(W=1). No hardware or fault-injection testing was performed.

 drivers/tty/serial/ip22zilog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c
index 3fb8fdf8a853..b2a9c9652924 100644
--- a/drivers/tty/serial/ip22zilog.c
+++ b/drivers/tty/serial/ip22zilog.c
@@ -1140,8 +1140,8 @@ static int __init ip22zilog_init(void)
 
 static void __exit ip22zilog_exit(void)
 {
-	uart_unregister_driver(&ip22zilog_reg);
 	platform_driver_unregister(&ip22zilog_driver);
+	uart_unregister_driver(&ip22zilog_reg);
 }
 
 module_init(ip22zilog_init);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] tty: serial: samsung: Fix potential NULL dereference on removal
  2026-11-03  0:45 [PATCH 0/2] tty: serial: Keep UART driver state until ports are removed Guangshuo Li
  2026-11-03  0:45 ` [PATCH 1/2] tty: serial: ip22zilog: Fix potential NULL dereference on exit Guangshuo Li
@ 2026-11-03  0:45 ` Guangshuo Li
  2026-11-03  0:53   ` sashiko-bot
  1 sibling, 1 reply; 5+ messages in thread
From: Guangshuo Li @ 2026-11-03  0:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Guangshuo Li, Krzysztof Kozlowski, Peter Griffin, Alim Akhtar,
	Tushar Behera, linux-arm-kernel, linux-samsung-soc, linux-kernel,
	linux-serial

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@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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] tty: serial: ip22zilog: Fix potential NULL dereference on exit
  2026-11-03  0:45 ` [PATCH 1/2] tty: serial: ip22zilog: Fix potential NULL dereference on exit Guangshuo Li
@ 2026-11-03  0:50   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-03  0:50 UTC (permalink / raw)
  To: Guangshuo Li; +Cc: linux-serial

> uart_unregister_driver() frees and clears the shared UART state before
> platform driver removal calls uart_remove_one_port(), which still needs
> that state.
> 
> Remove the ports before unregistering the UART driver.
> 
> This issue was found by our static analysis tool under development.
> 
> Fixes: 3fc36ae6abd2 ("tty: serial: ip22zilog: Use platform device for probing")
> Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103-cmc-tty-0-f5f5ec0841@mail.sdu.edu.cn?part=1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] tty: serial: samsung: Fix potential NULL dereference on removal
  2026-11-03  0:45 ` [PATCH 2/2] tty: serial: samsung: Fix potential NULL dereference on removal Guangshuo Li
@ 2026-11-03  0:53   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-03  0:53 UTC (permalink / raw)
  To: Guangshuo Li; +Cc: linux-serial

> 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@mail.sdu.edu.cn>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103-cmc-tty-0-f5f5ec0841@mail.sdu.edu.cn?part=2


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-03  0:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03  0:45 [PATCH 0/2] tty: serial: Keep UART driver state until ports are removed Guangshuo Li
2026-11-03  0:45 ` [PATCH 1/2] tty: serial: ip22zilog: Fix potential NULL dereference on exit Guangshuo Li
2026-11-03  0:50   ` sashiko-bot
2026-11-03  0:45 ` [PATCH 2/2] tty: serial: samsung: Fix potential NULL dereference on removal Guangshuo Li
2026-11-03  0:53   ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.