Re: [PATCH] ACPI: sysfs: Fix reference count leak in acpi_sysfs_add_hotplug_profile.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 27, 2020 at 11:17 PM <wu000273@xxxxxxx> wrote:
>
> From: Qiushi Wu <wu000273@xxxxxxx>
>
> 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@xxxxxxx>
> ---
>  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!



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux