[PATCH 2/2] genirq: proc: fix a procfs entry leak
From: Bartosz Golaszewski
Date: Mon Aug 14 2023 - 05:37:32 EST
From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
When removing the proc entry for a desc that still has active users, we
will leak the irqaction entries. Let's remove them in
unregister_irq_proc().
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
---
kernel/irq/proc.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 83ed403991c6..b284604a091a 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -390,6 +390,15 @@ void register_irq_proc(unsigned int irq, struct irq_desc *desc)
mutex_unlock(®ister_lock);
}
+static void unregister_action_proc(struct irqaction *action)
+{
+ if (!action)
+ return;
+
+ unregister_action_proc(action->secondary);
+ unregister_handler_proc(action);
+}
+
void unregister_irq_proc(unsigned int irq, struct irq_desc *desc)
{
char name [MAX_NAMELEN];
@@ -408,6 +417,12 @@ void unregister_irq_proc(unsigned int irq, struct irq_desc *desc)
#endif
remove_proc_entry("spurious", desc->dir);
+ /*
+ * If at this point, this irq desc is still requested, we need to
+ * remove the proc handler entries or we'll leak them.
+ */
+ unregister_action_proc(desc->action);
+
sprintf(name, "%u", irq);
remove_proc_entry(name, root_irq_dir);
}
--
2.39.2