PM / Domains: Fix memory leak on error path in pm_genpd_attach_cpuidle
authorjhbird.choi@samsung.com <jhbird.choi@samsung.com>
Mon, 22 Oct 2012 22:54:38 +0000 (00:54 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 22 Oct 2012 22:54:38 +0000 (00:54 +0200)
If pm_genpd_attach_cpudidle failed we leak memory stored in 'cpu_data'.

Signed-off-by: Jonghwan Choi <jhbird.choi@samsung.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/domain.c

index c22b869245d9498e7052fdc42ceacf3aaa4e332e..96b71b6536d61cef381dab119533b4a0b13f542e 100644 (file)
@@ -1862,7 +1862,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
        cpuidle_drv = cpuidle_driver_ref();
        if (!cpuidle_drv) {
                ret = -ENODEV;
-               goto out;
+               goto err_drv;
        }
        if (cpuidle_drv->state_count <= state) {
                ret = -EINVAL;
@@ -1884,6 +1884,9 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
 
  err:
        cpuidle_driver_unref();
+
+ err_drv:
+       kfree(cpu_data);
        goto out;
 }