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

ACPI: sysfs: Fix reference count leak in acpi_sysfs_add_hotplug_profile()

stable inclusion
from linux-4.19.129
commit efb4903f931a5955ee34fd1be89efa601b761961

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

commit 6e6c2528 upstream.

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: 3f8055c3 ("ACPI / hotplug: Introduce user space interface for hotplug profiles")
Signed-off-by: NQiushi Wu <wu000273@umn.edu>
Cc: 3.10+ <stable@vger.kernel.org> # 3.10+
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 c5119f38
...@@ -990,8 +990,10 @@ void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug, ...@@ -990,8 +990,10 @@ void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug,
error = kobject_init_and_add(&hotplug->kobj, error = kobject_init_and_add(&hotplug->kobj,
&acpi_hotplug_profile_ktype, hotplug_kobj, "%s", name); &acpi_hotplug_profile_ktype, hotplug_kobj, "%s", name);
if (error) if (error) {
kobject_put(&hotplug->kobj);
goto err_out; goto err_out;
}
kobject_uevent(&hotplug->kobj, KOBJ_ADD); kobject_uevent(&hotplug->kobj, KOBJ_ADD);
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册