lkml.org 
[lkml]   [2023]   [Aug]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] genirq: proc: fix a procfs entry leak
Date
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

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@linaro.org>
---
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(&register_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
\
 
 \ /
  Last update: 2023-08-14 11:38    [W:0.176 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site