]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
pps: clients: gpio: fix interrupt handling order in remove path
authorEliav Farber <farbere@amazon.com>
Tue, 27 May 2025 05:33:55 +0000 (05:33 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:25:53 +0000 (16:25 +0200)
commit5b5140acdf59a3f4d441252c03bd63846ff1ffd1
tree0c4035c4b0a4990e601d6c2231625ba8edb1b848
parent52300ba7f2245777201be5fa6f80848b21ffc092
pps: clients: gpio: fix interrupt handling order in remove path

[ Upstream commit 6bca1e955830808dc90e0506b2951b4256b81bbb ]

The interrupt handler in pps_gpio_probe() is registered after calling
pps_register_source() using devm_request_irq(). However, in the
corresponding remove function, pps_unregister_source() is called before
the IRQ is freed, since devm-managed resources are released after the
remove function completes.

This creates a potential race condition where an interrupt may occur
after the PPS source is unregistered but before the handler is removed,
possibly leading to a kernel panic.

To prevent this, switch from devm-managed IRQ registration to manual
management by using request_irq() and calling free_irq() explicitly in
the remove path before unregistering the PPS source. This ensures the
interrupt handler is safely removed before deactivating the PPS source.

Signed-off-by: Eliav Farber <farbere@amazon.com>
Link: https://lore.kernel.org/r/20250527053355.37185-1-farbere@amazon.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pps/clients/pps-gpio.c