Skip to contentSkip to conversation

x86/ioapic: fix the irq_2_pin mem leak when destroy_irq

PATCH In review Chuansheng Liu 2 participants 4 messages Oct 17, 2012 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/ioapic: fix the irq_2_pin mem leak when destroy_irq

When destroying the irq, before free cfg, need to check cfg->irq_2_pin and free it when it is not NULL.

---
 arch/x86/kernel/apic/io_apic.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
arch/x86/kernel/apic/io_apic.c +10 -0
index c265593..a976ee3 100644
@@ -201,6 +201,15 @@ static struct irq_pin_list *alloc_irq_pin_list(int node)
 	return kzalloc_node(sizeof(struct irq_pin_list), GFP_KERNEL, node);
 }
 
+static void free_irq_pin_list(struct irq_cfg *cfg)
+{
+	struct irq_pin_list *entry, *next;
+
+	for (entry = cfg->irq_2_pin; entry; entry = next) {
+		next = entry->next;
+		kfree(entry);
+	}
+}
 
 /* irq_cfg is indexed by the sum of all RTEs in all I/O APICs. */
 static struct irq_cfg irq_cfgx[NR_IRQS_LEGACY];
@@ -276,6 +285,7 @@ static void free_irq_cfg(unsigned int at, struct irq_cfg *cfg)
 	irq_set_chip_data(at, NULL);
 	free_cpumask_var(cfg->domain);
 	free_cpumask_var(cfg->old_domain);
+	free_irq_pin_list(cfg);
 	kfree(cfg);
 }
 
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 6 lines · Chuansheng Liu

When destroying the irq, before free cfg, need to check cfg->irq_2_pin and free it when it is not NULL.

---

i had that in another patch...

https://lkml.org/lkml/2012/2/23/574

----
Subject [PATCH 01/13] x86, irq: Convert irq_2_pin list to generic list
Date Thu, 23 Feb 2012 19:48:47 -0800

So we can use generic list helper function.

Also make free_irq_cfg() free irq_2_pin list.
----

http://git.kernel.org/?p=linux/kernel/git/yinghai/linux-yinghai.git;a=commitdiff;h=4010f4dbd1b172e3080d3e6c459a58c4b575f081

Yinghai

#2 lore raw
Quoted 15 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Yinghai Lu
Sent: Wednesday, October 17, 2012 10:03 AM
To: Liu, Chuansheng
Cc: [email protected]; [email protected]; Siddha, Suresh B; [email protected]
Subject: Re: [PATCH] x86/ioapic: fix the irq_2_pin mem leak when destroy_irq

Quoted 4 lines · Chuansheng Liu

When destroying the irq, before free cfg, need to check cfg->irq_2_pin and free it when it is not NULL.

Quoted 6 lines
Quoted 2 lines

---

i had that in another patch...

https://lkml.org/lkml/2012/2/23/574

Sorry to not know that.

Quoted 6 lines

----
Subject [PATCH 01/13] x86, irq: Convert irq_2_pin list to generic list
Date Thu, 23 Feb 2012 19:48:47 -0800

So we can use generic list helper function.

Does it really need the generic list with both prev and next pointers? For irq_2_pin list, the next pointer seems be enough.

Quoted 8 lines

Also make free_irq_cfg() free irq_2_pin list.
----

http://git.kernel.org/?p=linux/kernel/git/yinghai/linux-yinghai.git;a=commitdiff;
h=4010f4dbd1b172e3080d3e6c459a58c4b575f081

Yinghai

#3 lore raw
Quoted 3 lines · Chuansheng
Quoted 1 line

So we can use generic list helper function.

Does it really need the generic list with both prev and next pointers? For irq_2_pin list, the next pointer seems be enough.

generic version should be always better than home grown one.