File fix-memory-leak-in-classify-code.patch of Package irqbalance.3491

From: Tom Li <biergaizi2009@gmail.com>
Date: Fri, 18 Apr 2014 20:06:18 -0400
Subject: fix memory leak in classify code
References: bsc#1000291
Patch-mainline: v1.0.8
Git-commit: 699deffdd881bf4759f3fcc4d6ee3e018e4c266e
Git-repo: github.com/Irqbalance/irqbalance

If a system has no pci devices the opening of the pci bus directory in
rebuild_irq_db will fail, leading to a memory leak.  Fix it by freeing the list
we create in that function always on exit

Reported-by: Tom Li <biergaizi2009@gmail.com>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Tom Li <biergaizi2009@gmail.com>
[sparschauer: backport, reproducible in AWS EC2 PV VM w. >= 2 vCPUs]
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
 classify.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: irqbalance-1.0.7/classify.c
===================================================================
--- irqbalance-1.0.7.orig/classify.c
+++ irqbalance-1.0.7/classify.c
@@ -542,7 +542,7 @@ void rebuild_irq_db(void)
 
 	devdir = opendir(SYSDEV_DIR);
 	if (!devdir)
-		return;
+		goto free;
 
 	do {
 		entry = readdir(devdir);
@@ -559,6 +559,7 @@ void rebuild_irq_db(void)
 
 	for_each_irq(tmp_irqs, add_missing_irq, NULL);
 
+free:
 	g_list_free_full(tmp_irqs, free);
 
 }
openSUSE Build Service is sponsored by