From 71b77697af9ef06b559875e4bd8dc3d141807c93 Mon Sep 17 00:00:00 2001 From: Ulf Hansson Date: Thu, 18 Apr 2019 12:27:55 +0200 Subject: [PATCH] PM / Domains: Don't kfree() the virtual device in the error path 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 Acked-by: Viresh Kumar Acked-by: Niklas Cassel Signed-off-by: Rafael J. Wysocki --- drivers/base/power/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 598a4e02aee1..5422fc01dca3 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -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); } -- GitLab