Message ID | 01711a86da59f30b33e1c32aa29cc9b378d0c627.1417167599.git.viresh.kumar@linaro.org (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Eduardo Valentin |
Headers | show |
On Fri, Nov 28, 2014 at 09:44:09AM +0000, Viresh Kumar wrote: > This makes life easy and bug free. And is scalable for future resource > allocations. > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Yay! We have a similar fix as part of our patches for the power allocator governor (the only difference is that the instead of calling the label "remove_idr", we call it "release_idr"). So quite happy to see this going in. FWIW, Acked-by: Javi Merino <javi.merino@arm.com> -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 41aa7d5..032cba3 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -440,8 +440,8 @@ __cpufreq_cooling_register(struct device_node *np, ret = get_idr(&cpufreq_idr, &cpufreq_dev->id); if (ret) { - kfree(cpufreq_dev); - return ERR_PTR(cpufreq_dev->id); + cool_dev = ERR_PTR(cpufreq_dev->id); + goto free_cdev; } snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d", @@ -449,11 +449,9 @@ __cpufreq_cooling_register(struct device_node *np, cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev, &cpufreq_cooling_ops); - if (IS_ERR(cool_dev)) { - release_idr(&cpufreq_idr, cpufreq_dev->id); - kfree(cpufreq_dev); - return cool_dev; - } + if (IS_ERR(cool_dev)) + goto remove_idr; + cpufreq_dev->cool_dev = cool_dev; mutex_lock(&cooling_cpufreq_lock); @@ -467,6 +465,13 @@ __cpufreq_cooling_register(struct device_node *np, mutex_unlock(&cooling_cpufreq_lock); return cool_dev; + +remove_idr: + release_idr(&cpufreq_idr, cpufreq_dev->id); +free_cdev: + kfree(cpufreq_dev); + + return cool_dev; } /**
This makes life easy and bug free. And is scalable for future resource allocations. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> --- drivers/thermal/cpu_cooling.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)