* [PATCH] serial: xilinx_uartps: fix oops when disabling RS-485
@ 2026-11-13 14:50 Niko Mauno
2026-11-29 16:37 ` Eli Gavril
0 siblings, 1 reply; 2+ messages in thread
From: Niko Mauno @ 2026-11-13 14:50 UTC (permalink / raw)
To: gregkh, jirislaby, michal.simek
Cc: linux-serial, linux-kernel, linux-arm-kernel, jakub.turek,
andriy.shevchenko, Niko Mauno, stable
cdns_rs485_config() sets up tx_timer only when RS-485 is enabled, but
cancels it when RS-485 is disabled. A TIOCSRS485 that disables RS-485
on a port that was never in RS-485 mode cancels a zero-filled hrtimer
and oopses:
Unable to handle kernel NULL pointer dereference at virtual address 0000000c when read
PC is at hrtimer_active+0x4/0x94
LR is at hrtimer_cancel+0x10/0x64
...
Call trace:
hrtimer_active from hrtimer_cancel+0x10/0x64
hrtimer_cancel from cdns_rs485_config+0x10c/0x11c
cdns_rs485_config from uart_ioctl+0x7a4/0xc3c
uart_ioctl from tty_ioctl+0x3ec/0xbcc
Set the timer up once in probe instead. This also stops a TIOCSRS485
that enables RS-485 again from re-initialising the timer while a
transmit delay may have it queued. The callback is switched at run
time by the existing call sites, so its initial value does not matter.
Fixes: fccc9d9233f9 ("tty: serial: uartps: Add rs485 support to uartps driver")
Cc: stable@vger.kernel.org
Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
---
Tested on a Zynq-7000 board on 6.12.y: without this patch the first
TIOCSRS485 that disables RS-485 after boot oopses as above; with it,
repeated enable/transmit/disable cycles run clean. Also reproduced and
verified on v7.4-rc1 in QEMU.
drivers/tty/serial/xilinx_uartps.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index e8c4b1fa7658..f93e374f6d0e 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -1620,10 +1620,6 @@ static int cdns_rs485_config(struct uart_port *port, struct ktermios *termios,
val &= ~CDNS_UART_MODEMCR_FCM;
writel(val, port->membase + CDNS_UART_MODEMCR);
- /* Timer setup */
- hrtimer_setup(&cdns_uart->tx_timer, &cdns_rs485_tx_callback, CLOCK_MONOTONIC,
- HRTIMER_MODE_REL);
-
/* Disable transmitter and make Rx setup*/
cdns_uart_stop_tx(port);
} else {
@@ -1782,6 +1778,8 @@ static int cdns_uart_probe(struct platform_device *pdev)
port->rs485_config = cdns_rs485_config;
port->rs485_supported = cdns_rs485_supported;
cdns_uart_data->port = port;
+ hrtimer_setup(&cdns_uart_data->tx_timer, &cdns_rs485_tx_callback,
+ CLOCK_MONOTONIC, HRTIMER_MODE_REL);
platform_set_drvdata(pdev, port);
rc = uart_get_rs485_mode(port);
base-commit: 067c5c24cef23d913b67eaaf71ae67e7169a6620
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] serial: xilinx_uartps: fix oops when disabling RS-485
2026-11-13 14:50 [PATCH] serial: xilinx_uartps: fix oops when disabling RS-485 Niko Mauno
@ 2026-11-29 16:37 ` Eli Gavril
0 siblings, 0 replies; 2+ messages in thread
From: Eli Gavril @ 2026-11-29 16:37 UTC (permalink / raw)
To: Niko Mauno
Cc: gregkh, jirislaby, michal.simek, linux-serial, linux-kernel,
linux-arm-kernel, jakub.turek, andriy.shevchenko, stable
Hit the same oops on a Zynq UltraScale+ RFSoC (XCZU47DR, arm64) when
minicom opened a uartps port. With this patch on 6.18, disabling,
enabling and disabling RS-485 again with TIOCSRS485 on ttyPS1 runs
without an oops.
Tested-by: Eli Gavril <eli.gavril@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-29 16:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 14:50 [PATCH] serial: xilinx_uartps: fix oops when disabling RS-485 Niko Mauno
2026-11-29 16:37 ` Eli Gavril
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®