* [PATCH] tty: serial: ip22zilog: Free the interrupt on unbind
@ 2026-12-01 19:20 Arina Kharlamova via B4 Relay
2026-12-01 19:35 ` sashiko-bot
2026-12-01 20:07 ` Greg Kroah-Hartman
0 siblings, 2 replies; 3+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:20 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Thomas Bogendoerfer
Cc: linux-kernel, linux-serial, stable, Arina Kharlamova
From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
ip22zilog_probe() requests the interrupt with request_irq(), and
nothing frees it. After the driver is unbound the handler stays
installed, and the next probe fails to request the interrupt and
calls panic().
Request the interrupt with devm_request_irq(), so it is freed when the
driver is unbound.
Fixes: 3fc36ae6abd2 ("tty: serial: ip22zilog: Use platform device for probing")
Cc: stable@vger.kernel.org
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
The interrupt is never freed, so binding the driver again panics.
I found this with spec2patch. It has formal specifications of kernel APIs
such as devres, runtime PM, clocks and locks. Each one says what a call
acquires and releases and what a driver has to undo on the error and
remove paths. I checked this driver against them. With the help of an AI
coding assistant (Claude); I reviewed the analysis and the fix.
Compile-tested only, not tested on hardware.
---
drivers/tty/serial/ip22zilog.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c
index 3fb8fdf8a853..e887e01fb4d4 100644
--- a/drivers/tty/serial/ip22zilog.c
+++ b/drivers/tty/serial/ip22zilog.c
@@ -1091,8 +1091,8 @@ static int ip22zilog_probe(struct platform_device *pdev)
up->port.dev = &pdev->dev;
up->port.irq = irq;
- if (request_irq(irq, ip22zilog_interrupt, 0,
- "IP22-Zilog", NULL)) {
+ if (devm_request_irq(&pdev->dev, irq, ip22zilog_interrupt, 0,
+ "IP22-Zilog", NULL)) {
panic("IP22-Zilog: Unable to register zs interrupt handler.\n");
}
---
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
change-id: 20261201-s2p-d26-c6c65714abb8
Best regards,
--
Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] tty: serial: ip22zilog: Free the interrupt on unbind
2026-12-01 19:20 [PATCH] tty: serial: ip22zilog: Free the interrupt on unbind Arina Kharlamova via B4 Relay
@ 2026-12-01 19:35 ` sashiko-bot
2026-12-01 20:07 ` Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-01 19:35 UTC (permalink / raw)
To: Arina Kharlamova; +Cc: linux-serial
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] tty: serial: ip22zilog: race between IRQ and port
teardown/re-init in ip22zilog_probe()
--
commit d9c7f1ddd8187e669adae449f28b7838ada8e286
Author: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
tty: serial: ip22zilog: Free the interrupt on unbind
This commit switches ip22zilog_probe() from request_irq() to
devm_request_irq() so the interrupt handler is freed when the driver is
unbound.
> diff --git a/drivers/tty/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c
> index 3fb8fdf8a853a..e887e01fb4d46 100644
> --- a/drivers/tty/serial/ip22zilog.c
> +++ b/drivers/tty/serial/ip22zilog.c
> @@ -1091,8 +1091,8 @@ static int ip22zilog_probe(struct platform_device *pdev)
> up->port.dev = &pdev->dev;
> up->port.irq = irq;
>
> - if (request_irq(irq, ip22zilog_interrupt, 0,
> - "IP22-Zilog", NULL)) {
> + if (devm_request_irq(&pdev->dev, irq, ip22zilog_interrupt, 0,
> + "IP22-Zilog", NULL)) {
> panic("IP22-Zilog: Unable to register zs interrupt handler.\n");
> }
[Severity: Medium]
Can using devm_request_irq() here leave ip22zilog_interrupt() active
while the ports are being removed on unbind or re-initialized on a later
bind?
On unbind, __device_release_driver() runs ip22zilog_remove() before
devres releases the IRQ. For a console port, ip22zilog_shutdown() leaves
Z8530 interrupts enabled, and uart_remove_one_port() detaches the port
without clearing up->port.state in the static ip22zilog_port_table[].
If the driver is then bound again, devm_request_irq() installs
ip22zilog_interrupt() before uart_add_one_port() runs:
CPU0 CPU1 (<hardirq>)
ip22zilog_probe()
devm_request_irq()
ip22zilog_interrupt()
uart_port_lock(&up->port)
uart_add_one_port()
...
uart_port_spin_lock_init() <-- re-inits held lock
An interrupt during unbind or re-probe can also see the stale
up->port.state pointer in ip22zilog_receive_chars() or
ip22zilog_transmit_chars() and push flip-buffer work or wakeups on a
removed port, or corrupt up->port.lock.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-s2p-d26-v1-1-a39b4ded58a6@mbzuai.ac.ae?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] tty: serial: ip22zilog: Free the interrupt on unbind
2026-12-01 19:20 [PATCH] tty: serial: ip22zilog: Free the interrupt on unbind Arina Kharlamova via B4 Relay
2026-12-01 19:35 ` sashiko-bot
@ 2026-12-01 20:07 ` Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-01 20:07 UTC (permalink / raw)
To: arina.kharlamova
Cc: Jiri Slaby, Thomas Bogendoerfer, linux-kernel, linux-serial,
stable
On Tue, Dec 01, 2026 at 11:20:52PM +0400, Arina Kharlamova via B4 Relay wrote:
> From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
>
> ip22zilog_probe() requests the interrupt with request_irq(), and
> nothing frees it. After the driver is unbound the handler stays
> installed, and the next probe fails to request the interrupt and
> calls panic().
>
> Request the interrupt with devm_request_irq(), so it is freed when the
> driver is unbound.
Then don't call unbound :)
>
> Fixes: 3fc36ae6abd2 ("tty: serial: ip22zilog: Use platform device for probing")
> Cc: stable@vger.kernel.org
> Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
> ---
> The interrupt is never freed, so binding the driver again panics.
>
> I found this with spec2patch. It has formal specifications of kernel APIs
> such as devres, runtime PM, clocks and locks. Each one says what a call
> acquires and releases and what a driver has to undo on the error and
> remove paths. I checked this driver against them. With the help of an AI
> coding assistant (Claude); I reviewed the analysis and the fix.
> Compile-tested only, not tested on hardware.
Please test on real hardware, devm_request_irq() has BAD side affects if
used incorrectly.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-01 20:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 19:20 [PATCH] tty: serial: ip22zilog: Free the interrupt on unbind Arina Kharlamova via B4 Relay
2026-12-01 19:35 ` sashiko-bot
2026-12-01 20:07 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox