PM / Domains: Don't kfree() the virtual device in the error path
authorUlf Hansson <ulf.hansson@linaro.org>
Thu, 18 Apr 2019 10:27:55 +0000 (12:27 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 25 Apr 2019 07:37:28 +0000 (09:37 +0200)
It's not correct to call kfree(dev) when device_register(dev) has failed.

Fix this by calling put_device(dev) instead.

Fixes: 3c095f32a92b ("PM / Domains: Add support for multi PM domains per device to genpd")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Niklas Cassel <niklas.cassel@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/domain.c

index 598a4e02aee19e1152b8e692dbc3cd64852716e7..5422fc01dca3a7514b5f1f20d93dd1e3ea34c9de 100644 (file)
@@ -2455,7 +2455,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev,
 
        ret = device_register(virt_dev);
        if (ret) {
-               kfree(virt_dev);
+               put_device(virt_dev);
                return ERR_PTR(ret);
        }