mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-31 04:01:48 -04:00
cpuidle: Fix three reference count leaks
[ Upstream commit c343bf1ba5efcbf2266a1fe3baefec9cc82f867f ]
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 "b8eb718348" fixed a similar problem.
Signed-off-by: Qiushi Wu <[email protected]>
[ rjw: Subject ]
Signed-off-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
This commit is contained in:
parent
cf33598698
commit
b77412359c
1 changed files with 3 additions and 3 deletions
|
|
@ -480,7 +480,7 @@ static int cpuidle_add_state_sysfs(struct cpuidle_device *device)
|
|||
ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle,
|
||||
&kdev->kobj, "state%d", i);
|
||||
if (ret) {
|
||||
kfree(kobj);
|
||||
kobject_put(&kobj->kobj);
|
||||
goto error_state;
|
||||
}
|
||||
cpuidle_add_s2idle_attr_group(kobj);
|
||||
|
|
@ -611,7 +611,7 @@ static int cpuidle_add_driver_sysfs(struct cpuidle_device *dev)
|
|||
ret = kobject_init_and_add(&kdrv->kobj, &ktype_driver_cpuidle,
|
||||
&kdev->kobj, "driver");
|
||||
if (ret) {
|
||||
kfree(kdrv);
|
||||
kobject_put(&kdrv->kobj);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -705,7 +705,7 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)
|
|||
error = kobject_init_and_add(&kdev->kobj, &ktype_cpuidle, &cpu_dev->kobj,
|
||||
"cpuidle");
|
||||
if (error) {
|
||||
kfree(kdev);
|
||||
kobject_put(&kdev->kobj);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue