diff mbox series

ACPI: CPPC: Fix reference count leak in acpi_cppc_processor_probe.

Message ID 20200527223551.20156-1-wu000273@umn.edu (mailing list archive)
State Mainlined, archived
Headers show
Series ACPI: CPPC: Fix reference count leak in acpi_cppc_processor_probe. | expand

Commit Message

wu000273@umn.edu May 27, 2020, 10:35 p.m. UTC
From: Qiushi Wu <wu000273@umn.edu>

kobject_init_and_add() takes reference even when it fails.
If this function returns an error, kobject_put() must be called to
properly clean up the memory associated with the object. Previous
commit "b8eb718348b8" fixed a similar problem.

Fixes: 158c998ea44b ("ACPI / CPPC: add sysfs support to compute delivered performance")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
 drivers/acpi/cppc_acpi.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Rafael J. Wysocki May 28, 2020, 11:49 a.m. UTC | #1
On Thu, May 28, 2020 at 12:45 AM <wu000273@umn.edu> wrote:
>
> From: Qiushi Wu <wu000273@umn.edu>
>
> kobject_init_and_add() takes reference even when it fails.
> If this function returns an error, kobject_put() must be called to
> properly clean up the memory associated with the object. Previous
> commit "b8eb718348b8" fixed a similar problem.
>
> Fixes: 158c998ea44b ("ACPI / CPPC: add sysfs support to compute delivered performance")
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
> ---
>  drivers/acpi/cppc_acpi.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index 8b2e89c20c11..067067bc03d4 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -846,6 +846,7 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
>                         "acpi_cppc");
>         if (ret) {
>                 per_cpu(cpc_desc_ptr, pr->id) = NULL;
> +               kobject_put(&cpc_ptr->kobj);
>                 goto out_free;
>         }
>
> --

Applied as 5.8 material, thanks!
diff mbox series

Patch

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 8b2e89c20c11..067067bc03d4 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -846,6 +846,7 @@  int acpi_cppc_processor_probe(struct acpi_processor *pr)
 			"acpi_cppc");
 	if (ret) {
 		per_cpu(cpc_desc_ptr, pr->id) = NULL;
+		kobject_put(&cpc_ptr->kobj);
 		goto out_free;
 	}