From: Qiushi Wu Date: Wed, 27 May 2020 21:17:17 +0000 (-0500) Subject: ACPI: sysfs: Fix reference count leak in acpi_sysfs_add_hotplug_profile() X-Git-Tag: v5.10.7~2501^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6e6c25283dff866308c87b49434c7dbad4774cc0;p=platform%2Fkernel%2Flinux-rpi.git 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: 3f8055c35836 ("ACPI / hotplug: Introduce user space interface for hotplug profiles") Signed-off-by: Qiushi Wu Cc: 3.10+ # 3.10+ Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index c60d2c6..3a89909 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c @@ -993,8 +993,10 @@ void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug, error = kobject_init_and_add(&hotplug->kobj, &acpi_hotplug_profile_ktype, hotplug_kobj, "%s", name); - if (error) + if (error) { + kobject_put(&hotplug->kobj); goto err_out; + } kobject_uevent(&hotplug->kobj, KOBJ_ADD); return;