* [PATCH] ACPI: sysfs: Fix reference count leak in acpi_sysfs_add_hotplug_profile.
@ 2020-05-27 21:17 wu000273
2020-05-28 11:50 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: wu000273 @ 2020-05-27 21:17 UTC (permalink / raw)
To: kjlu
Cc: wu000273, Rafael J. Wysocki, Len Brown, Toshi Kani, linux-acpi,
linux-kernel
From: Qiushi Wu <wu000273@umn.edu>
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 <wu000273@umn.edu>
---
drivers/acpi/sysfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index c60d2c6d31d6..3a89909b50a6 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;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ACPI: sysfs: Fix reference count leak in acpi_sysfs_add_hotplug_profile.
2020-05-27 21:17 [PATCH] ACPI: sysfs: Fix reference count leak in acpi_sysfs_add_hotplug_profile wu000273
@ 2020-05-28 11:50 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2020-05-28 11:50 UTC (permalink / raw)
To: wu000273
Cc: Kangjie Lu, Rafael J. Wysocki, Len Brown, Toshi Kani,
ACPI Devel Maling List, Linux Kernel Mailing List
On Wed, May 27, 2020 at 11:17 PM <wu000273@umn.edu> wrote:
>
> From: Qiushi Wu <wu000273@umn.edu>
>
> 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 <wu000273@umn.edu>
> ---
> drivers/acpi/sysfs.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
> index c60d2c6d31d6..3a89909b50a6 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;
> --
Applied as 5.8 material, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-28 11:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 21:17 [PATCH] ACPI: sysfs: Fix reference count leak in acpi_sysfs_add_hotplug_profile wu000273
2020-05-28 11:50 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).