Skip to content

Commit 6e6c252

Browse files
QiushiWurafaeljw
authored andcommitted
ACPI: sysfs: Fix reference count leak in acpi_sysfs_add_hotplug_profile()
kobject_init_and_add() takes reference even when it fails. Thus, when kobject_init_and_add() returns an error, kobject_put() must be called to properly clean up the kobject. Fixes: 3f8055c ("ACPI / hotplug: Introduce user space interface for hotplug profiles") Signed-off-by: Qiushi Wu <[email protected]> Cc: 3.10+ <[email protected]> # 3.10+ Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 9cb1fd0 commit 6e6c252

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/acpi/sysfs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,10 @@ void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug,
993993

994994
error = kobject_init_and_add(&hotplug->kobj,
995995
&acpi_hotplug_profile_ktype, hotplug_kobj, "%s", name);
996-
if (error)
996+
if (error) {
997+
kobject_put(&hotplug->kobj);
997998
goto err_out;
999+
}
9981000

9991001
kobject_uevent(&hotplug->kobj, KOBJ_ADD);
10001002
return;

0 commit comments

Comments
 (0)