* [PATCH 0/2] serial: release the port resources in release_port
@ 2026-12-01 19:20 Arina Kharlamova via B4 Relay
2026-12-01 19:20 ` [PATCH 1/2] serial: lantiq: release the memory region " Arina Kharlamova via B4 Relay
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:20 UTC (permalink / raw)
To: Jiri Slaby, John Crispin, Greg Kroah-Hartman
Cc: linux-kernel, linux-serial, stable, Arina Kharlamova
lantiq and pic32_uart get their port resources with devm in
request_port and do not release all of them in release_port. On lantiq
TIOCSERCONFIG then ends in a NULL pointer access, on pic32 each
TIOCSERCONFIG leaks a mapping.
I found this with spec2patch. I model-checked the probe and remove paths
of the driver with CBMC against formal specifications of the kernel APIs
it calls. The specifications are checked against the kernel source, and
some of them are proved in Rocq against a transcription of the kernel
code. I also checked lock usage separately. With the help of an AI
coding assistant (Claude); I reviewed the analysis and the fix.
Compile-tested only, not tested on hardware.
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Arina Kharlamova (2):
serial: lantiq: release the memory region in release_port
serial: pic32_uart: unmap the registers in release_port
drivers/tty/serial/lantiq.c | 6 ++++++
drivers/tty/serial/pic32_uart.c | 2 ++
2 files changed, 8 insertions(+)
---
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
change-id: 20261201-s2p-lpr-tty-49d26c5fa81d
Best regards,
--
Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] serial: lantiq: release the memory region in release_port
2026-12-01 19:20 [PATCH 0/2] serial: release the port resources in release_port Arina Kharlamova via B4 Relay
@ 2026-12-01 19:20 ` Arina Kharlamova via B4 Relay
2026-12-01 20:01 ` John Crispin
2026-12-01 19:20 ` [PATCH 2/2] serial: pic32_uart: unmap the registers " Arina Kharlamova via B4 Relay
2026-12-01 19:29 ` [PATCH 0/2] serial: release the port resources " sashiko-bot
2 siblings, 1 reply; 5+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:20 UTC (permalink / raw)
To: Jiri Slaby, John Crispin, Greg Kroah-Hartman
Cc: linux-kernel, linux-serial, stable, Arina Kharlamova
From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
lqasc_request_port() requests the memory region with
devm_request_mem_region(), but lqasc_release_port() only unmaps the
registers. After TIOCSERCONFIG, which calls release_port and then
config_port, the region is still busy and lqasc_request_port() fails.
lqasc_config_port() ignores the error, and lqasc_startup() then
accesses the registers through a NULL membase.
Release the region in lqasc_release_port().
Fixes: 2f0fc4159a6a ("SERIAL: Lantiq: Add driver for MIPS Lantiq SOCs.")
Cc: stable@vger.kernel.org
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
drivers/tty/serial/lantiq.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/tty/serial/lantiq.c b/drivers/tty/serial/lantiq.c
index fc75476c0935..37f74ecae937 100644
--- a/drivers/tty/serial/lantiq.c
+++ b/drivers/tty/serial/lantiq.c
@@ -498,11 +498,17 @@ static void
lqasc_release_port(struct uart_port *port)
{
struct platform_device *pdev = to_platform_device(port->dev);
+ struct resource *res;
if (port->flags & UPF_IOREMAP) {
devm_iounmap(&pdev->dev, port->membase);
port->membase = NULL;
}
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (res)
+ devm_release_mem_region(&pdev->dev, res->start,
+ resource_size(res));
}
static int
--
Git-157)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] serial: pic32_uart: unmap the registers in release_port
2026-12-01 19:20 [PATCH 0/2] serial: release the port resources in release_port Arina Kharlamova via B4 Relay
2026-12-01 19:20 ` [PATCH 1/2] serial: lantiq: release the memory region " Arina Kharlamova via B4 Relay
@ 2026-12-01 19:20 ` Arina Kharlamova via B4 Relay
2026-12-01 19:29 ` [PATCH 0/2] serial: release the port resources " sashiko-bot
2 siblings, 0 replies; 5+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:20 UTC (permalink / raw)
To: Jiri Slaby, John Crispin, Greg Kroah-Hartman
Cc: linux-kernel, linux-serial, Arina Kharlamova
From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
pic32_uart_request_port() maps the registers with devm_ioremap(), but
pic32_uart_release_port() only releases the memory region. The serial
core calls release_port and then config_port on every TIOCSERCONFIG,
so each call adds a mapping that stays until the driver is unbound.
Unmap the registers in pic32_uart_release_port().
Fixes: 157b9394709e ("serial: pic32_uart: Add PIC32 UART driver")
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
drivers/tty/serial/pic32_uart.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c
index a645b646bf8d..9a0f5073d273 100644
--- a/drivers/tty/serial/pic32_uart.c
+++ b/drivers/tty/serial/pic32_uart.c
@@ -710,6 +710,8 @@ static void pic32_uart_release_port(struct uart_port *port)
return;
res_size = resource_size(res_mem);
+ devm_iounmap(port->dev, port->membase);
+ port->membase = NULL;
release_mem_region(port->mapbase, res_size);
}
--
Git-157)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] serial: release the port resources in release_port
2026-12-01 19:20 [PATCH 0/2] serial: release the port resources in release_port Arina Kharlamova via B4 Relay
2026-12-01 19:20 ` [PATCH 1/2] serial: lantiq: release the memory region " Arina Kharlamova via B4 Relay
2026-12-01 19:20 ` [PATCH 2/2] serial: pic32_uart: unmap the registers " Arina Kharlamova via B4 Relay
@ 2026-12-01 19:29 ` sashiko-bot
2 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-12-01 19:29 UTC (permalink / raw)
To: Arina Kharlamova; +Cc: linux-serial
Sashiko has reviewed this 2-patch series and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-s2p-lpr-tty-v1-0-599ae5139f12@mbzuai.ac.ae
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] serial: lantiq: release the memory region in release_port
2026-12-01 19:20 ` [PATCH 1/2] serial: lantiq: release the memory region " Arina Kharlamova via B4 Relay
@ 2026-12-01 20:01 ` John Crispin
0 siblings, 0 replies; 5+ messages in thread
From: John Crispin @ 2026-12-01 20:01 UTC (permalink / raw)
To: arina.kharlamova, Jiri Slaby, Greg Kroah-Hartman
Cc: linux-kernel, linux-serial, stable
On 01.12.26 20:20, Arina Kharlamova via B4 Relay wrote:
> From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
>
> lqasc_request_port() requests the memory region with
> devm_request_mem_region(), but lqasc_release_port() only unmaps the
> registers. After TIOCSERCONFIG, which calls release_port and then
> config_port, the region is still busy and lqasc_request_port() fails.
> lqasc_config_port() ignores the error, and lqasc_startup() then
> accesses the registers through a NULL membase.
>
> Release the region in lqasc_release_port().
>
> Fixes: 2f0fc4159a6a ("SERIAL: Lantiq: Add driver for MIPS Lantiq SOCs.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
> ---
> drivers/tty/serial/lantiq.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/tty/serial/lantiq.c b/drivers/tty/serial/lantiq.c
> index fc75476c0935..37f74ecae937 100644
> --- a/drivers/tty/serial/lantiq.c
> +++ b/drivers/tty/serial/lantiq.c
> @@ -498,11 +498,17 @@ static void
> lqasc_release_port(struct uart_port *port)
> {
> struct platform_device *pdev = to_platform_device(port->dev);
> + struct resource *res;
>
> if (port->flags & UPF_IOREMAP) {
> devm_iounmap(&pdev->dev, port->membase);
> port->membase = NULL;
> }
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (res)
> + devm_release_mem_region(&pdev->dev, res->start,
> + resource_size(res));
> }
>
> static int
>
The imbalance is there, but it only shows with TIOCSERCONFIG, which nobody runs on a SoC UART.
I do not think this is stable material, please drop the Cc: stable.
this feels like some rogue / fire and forget LLM report material
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-12-01 20:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 19:20 [PATCH 0/2] serial: release the port resources in release_port Arina Kharlamova via B4 Relay
2026-12-01 19:20 ` [PATCH 1/2] serial: lantiq: release the memory region " Arina Kharlamova via B4 Relay
2026-12-01 20:01 ` John Crispin
2026-12-01 19:20 ` [PATCH 2/2] serial: pic32_uart: unmap the registers " Arina Kharlamova via B4 Relay
2026-12-01 19:29 ` [PATCH 0/2] serial: release the port resources " sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox