[PATCH] auxdisplay: panel: free logical inputs on detach
From: Muhammad Mahdi Amirpour
Date: Sat Nov 28 2026 - 07:48:08 EST
Free all allocated logical inputs when the panel device is
detached or attachment fails.
Stop the scan timer before freeing the input list to prevent
the timer callback from accessing freed entries.
Reset the scan masks after releasing the inputs.
Signed-off-by: Muhammad Mahdi Amirpour <ampr.mhd@xxxxxxxxx>
---
drivers/auxdisplay/panel.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c
index 2a567a075e2b..f4d279816b53 100644
--- a/drivers/auxdisplay/panel.c
+++ b/drivers/auxdisplay/panel.c
@@ -1471,6 +1471,19 @@ static void keypad_init(void)
/* device initialization */
/**************************************************/
+static void panel_free_inputs(void)
+{
+ struct logical_input *input, *tmp;
+
+ list_for_each_entry_safe(input, tmp, &logical_inputs, list) {
+ list_del(&input->list);
+ kfree(input);
+ }
+
+ scan_mask_i = 0;
+ scan_mask_o = 0;
+}
+
static void panel_attach(struct parport *port)
{
int selected_keypad_type = NOT_SET;
@@ -1615,6 +1628,10 @@ static void panel_attach(struct parport *port)
err_lcd_unreg:
if (scan_timer.function)
timer_delete_sync(&scan_timer);
+
+ keypad_initialized = 0;
+ panel_free_inputs();
+
if (lcd.enabled)
charlcd_unregister(lcd.charlcd);
err_unreg_device:
@@ -1642,6 +1659,8 @@ static void panel_detach(struct parport *port)
keypad_initialized = 0;
}
+ panel_free_inputs();
+
if (lcd.enabled) {
charlcd_unregister(lcd.charlcd);
lcd.initialized = false;
@@ -1649,7 +1668,6 @@ static void panel_detach(struct parport *port)
lcd.charlcd = NULL;
}
- /* TODO: free all input signals */
parport_release(pprt);
parport_unregister_device(pprt);
pprt = NULL;
--
2.56.0