From d30d811151801cbbb1fb3d8956587e5b2e9295ca Mon Sep 17 00:00:00 2001 From: Xinghua Pan Date: Wed, 7 May 2025 09:46:01 -0400 Subject: [PATCH] Fix kernel panic when unload bh_threaded module Ensuring the free_irq function properly releases IRQs for buttons, call free_irq() with button's device handler instead of NULL. --- examples/bh_threaded.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/bh_threaded.c b/examples/bh_threaded.c index 8241f312..bb6a3328 100644 --- a/examples/bh_threaded.c +++ b/examples/bh_threaded.c @@ -156,7 +156,7 @@ static int __init bottomhalf_init(void) /* cleanup what has been setup so far */ #ifdef NO_GPIO_REQUEST_ARRAY fail4: - free_irq(button_irqs[0], NULL); + free_irq(button_irqs[0], &buttons[0]); fail3: gpio_free(buttons[1].gpio); @@ -168,7 +168,7 @@ static int __init bottomhalf_init(void) gpio_free(leds[0].gpio); #else fail3: - free_irq(button_irqs[0], NULL); + free_irq(button_irqs[0], &buttons[0]); fail2: gpio_free_array(buttons, ARRAY_SIZE(leds)); @@ -185,8 +185,8 @@ static void __exit bottomhalf_exit(void) pr_info("%s\n", __func__); /* free irqs */ - free_irq(button_irqs[0], NULL); - free_irq(button_irqs[1], NULL); + free_irq(button_irqs[0], &buttons[0]); + free_irq(button_irqs[1], &buttons[1]); /* turn all LEDs off */ #ifdef NO_GPIO_REQUEST_ARRAY