提交 f0c099e3 编写于 作者: Q Qiushi Wu 提交者: Yang Yingliang

cpuidle: Fix three reference count leaks

stable inclusion
from linux-4.19.129
commit fad0431b7e61b750ef798c1a739382dfae85e231

--------------------------------

[ Upstream commit c343bf1b ]

kobject_init_and_add() takes reference even when it fails.
If this function returns an error, kobject_put() must be called to
properly clean up the memory associated with the object.

Previous commit "b8eb7183" fixed a similar problem.
Signed-off-by: NQiushi Wu <wu000273@umn.edu>
[ rjw: Subject ]
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 8ded6e5e
...@@ -467,7 +467,7 @@ static int cpuidle_add_state_sysfs(struct cpuidle_device *device) ...@@ -467,7 +467,7 @@ static int cpuidle_add_state_sysfs(struct cpuidle_device *device)
ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle,
&kdev->kobj, "state%d", i); &kdev->kobj, "state%d", i);
if (ret) { if (ret) {
kfree(kobj); kobject_put(&kobj->kobj);
goto error_state; goto error_state;
} }
cpuidle_add_s2idle_attr_group(kobj); cpuidle_add_s2idle_attr_group(kobj);
...@@ -598,7 +598,7 @@ static int cpuidle_add_driver_sysfs(struct cpuidle_device *dev) ...@@ -598,7 +598,7 @@ static int cpuidle_add_driver_sysfs(struct cpuidle_device *dev)
ret = kobject_init_and_add(&kdrv->kobj, &ktype_driver_cpuidle, ret = kobject_init_and_add(&kdrv->kobj, &ktype_driver_cpuidle,
&kdev->kobj, "driver"); &kdev->kobj, "driver");
if (ret) { if (ret) {
kfree(kdrv); kobject_put(&kdrv->kobj);
return ret; return ret;
} }
...@@ -692,7 +692,7 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev) ...@@ -692,7 +692,7 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)
error = kobject_init_and_add(&kdev->kobj, &ktype_cpuidle, &cpu_dev->kobj, error = kobject_init_and_add(&kdev->kobj, &ktype_cpuidle, &cpu_dev->kobj,
"cpuidle"); "cpuidle");
if (error) { if (error) {
kfree(kdev); kobject_put(&kdev->kobj);
return error; return error;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册