Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH 0/4] serial: fix console lifetime bugs on failed bind and removal
@ 2026-07-19 16:08 Karl Mehltretter
  2026-07-19 16:08 ` [PATCH 1/4] serial: core: do fallible allocations before the console can be registered Karl Mehltretter
  2026-07-19 16:08 ` [PATCH 4/4] serial: imx: clear imx_uart_ports[] entry on probe failure and removal Karl Mehltretter
  0 siblings, 2 replies; 5+ messages in thread
From: Karl Mehltretter @ 2026-07-19 16:08 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Karl Mehltretter, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, linux-serial, linux-kernel, imx, linux-arm-kernel

This series fixes serial/tty lifetime bugs found while injecting
allocation failures into the UART bind path. The failures were
reproduced on QEMU's raspi1ap (amba-pl011) and mcimx6ul-evk (imx)
machines.

The first three patches fix shared serial/tty error paths: move
fallible port allocations before console registration, clear state
after failed uart_driver registration, and track whether a live cdev
is registered. The final patch fixes the lifetime of the i.MX driver's
private console-port table on probe failure and removal.

The i.MX probe-failure fix spans patches 1 and 4. Serial core must not
return an error while leaving the console registered, and the i.MX
driver must clear its table entry before the failed probe frees the
port.

With all four patches applied, fail-nth sweeps of the console UART bind
path completed on both machines without a KASAN report or oops. Every
failed bind left the console unregistered, and the i.MX unbind/rebind
reproducer also ran cleanly.

This follows up on the discussion here:
https://lore.kernel.org/r/alyjOGyTd19Obemi@MacBook-Pro-von-Karl

Karl Mehltretter (4):
  serial: core: do fallible allocations before the console can be
    registered
  serial: core: clear freed pointers on uart_register_driver() failure
  tty: don't oops in tty_unregister_device() when no cdev is registered
  serial: imx: clear imx_uart_ports[] entry on probe failure and removal

 drivers/tty/serial/imx.c         |  4 ++++
 drivers/tty/serial/serial_core.c | 33 ++++++++++++++++++-------------
 drivers/tty/tty_io.c             |  6 ++++--
 3 files changed, 27 insertions(+), 16 deletions(-)

-- 
2.53.0

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

end of thread, other threads:[~2026-07-19 22:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-19 16:08 [PATCH 0/4] serial: fix console lifetime bugs on failed bind and removal Karl Mehltretter
2026-07-19 16:08 ` [PATCH 1/4] serial: core: do fallible allocations before the console can be registered Karl Mehltretter
2026-07-19 16:08 ` [PATCH 4/4] serial: imx: clear imx_uart_ports[] entry on probe failure and removal Karl Mehltretter
2026-07-19 16:28   ` sashiko-bot
2026-07-19 22:02     ` Karl Mehltretter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox