Skip to contentSkip to conversation

thermal: cpu_cooling: small memory leak on error

PATCH In review Dan Carpenter 2 participants 2 messages Dec 16, 2014 – Dec 17, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: cpu_cooling: small memory leak on error

There was a left over return here so the error handling isn't run. It leads to a small memory leak and a static checker warning.

drivers/thermal/cpu_cooling.c:351 __cpufreq_cooling_register()
info: ignoring unreachable code.

drivers/thermal/cpu_cooling.c +0 -1
index 051eb48..9b45f64 100644
@@ -347,7 +347,6 @@ __cpufreq_cooling_register(struct device_node *np,
 	cpufreq_dev->freq_table = kmalloc(sizeof(*cpufreq_dev->freq_table) *
 					  cpufreq_dev->max_level, GFP_KERNEL);
 	if (!cpufreq_dev->freq_table) {
-		return ERR_PTR(-ENOMEM);
 		cool_dev = ERR_PTR(-ENOMEM);
 		goto free_cdev;
 	}
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Dan Carpenter

There was a left over return here so the error handling isn't run. It leads to a small memory leak and a static checker warning.

drivers/thermal/cpu_cooling.c:351 __cpufreq_cooling_register()
info: ignoring unreachable code.

Fixes f6859014c7e7 ("thermal: cpu_cooling: Store frequencies in

descending order")

drivers/thermal/cpu_cooling.c __cpufreq_cooling_register(struct device_node *np, · line 352

Quoted 13 lines
drivers/thermal/cpu_cooling.c +0 -1
index 051eb48..9b45f64 100644
@@ -347,7 +347,6 @@ __cpufreq_cooling_register(struct device_node *np,
        cpufreq_dev->freq_table = kmalloc(sizeof(*cpufreq_dev->freq_table) *
                                          cpufreq_dev->max_level, GFP_KERNEL);
        if (!cpufreq_dev->freq_table) {
-               return ERR_PTR(-ENOMEM);
                cool_dev = ERR_PTR(-ENOMEM);
                goto free_cdev;
        }