Skip to contentSkip to conversation

unbalanced try_get_module/put_module in cpufreq

PATCH Applied Charles Coffing 2 participants 2 messages Apr 21, 2004 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 unbalanced try_get_module/put_module in cpufreq

Hi,

This patch is against 2.6.5. There's a small bug in cpufreq_add_dev: If kmalloc fails, try_get_module() is not balanced by a module_put().

Thanks,
Charles

drivers/cpufreq/cpufreq.c +3 -0
diff -pu linux-2.6.5.orig/drivers/cpufreq/cpufreq.c linux-2.6.5/drivers/cpufreq/cpufreq.c
@@ -361,7 +361,10 @@ static int cpufreq_add_dev (struct sys_d
 
 	policy = kmalloc(sizeof(struct cpufreq_policy), GFP_KERNEL);
 	if (!policy)
+	{
+		module_put(cpufreq_driver->owner);
 		return -ENOMEM;
+	}
 	memset(policy, 0, sizeof(struct cpufreq_policy));
 
 	policy->cpu = cpu;
Applied
#1 lore raw
Quoted 4 lines · Charles Coffing

Hi,

This patch is against 2.6.5. There's a small bug in cpufreq_add_dev: If kmalloc fails, try_get_module() is not balanced by a module_put().

Thanks, applied. (Slightly different variant, but same end result).

Dave