Patch "ACPI: processor: Fix memory leaks in error paths of processor_add()" has been added to the 6.10-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    ACPI: processor: Fix memory leaks in error paths of processor_add()

to the 6.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     acpi-processor-fix-memory-leaks-in-error-paths-of-pr.patch
and it can be found in the queue-6.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9dc855e8cd3a290617b591fcaff389f4d838b357
Author: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
Date:   Wed May 29 14:34:32 2024 +0100

    ACPI: processor: Fix memory leaks in error paths of processor_add()
    
    [ Upstream commit 47ec9b417ed9b6b8ec2a941cd84d9de62adc358a ]
    
    If acpi_processor_get_info() returned an error, pr and the associated
    pr->throttling.shared_cpu_map were leaked.
    
    The unwind code was in the wrong order wrt to setup, relying on
    some unwind actions having no affect (clearing variables that were
    never set etc).  That makes it harder to reason about so reorder
    and add appropriate labels to only undo what was actually set up
    in the first place.
    
    Acked-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
    Reviewed-by: Gavin Shan <gshan@xxxxxxxxxx>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240529133446.28446-6-Jonathan.Cameron@xxxxxxxxxx
    Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index c052cdeca9fd..5f5a01ccfc3a 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -400,7 +400,7 @@ static int acpi_processor_add(struct acpi_device *device,
 
 	result = acpi_processor_get_info(device);
 	if (result) /* Processor is not physically present or unavailable */
-		return result;
+		goto err_clear_driver_data;
 
 	BUG_ON(pr->id >= nr_cpu_ids);
 
@@ -415,7 +415,7 @@ static int acpi_processor_add(struct acpi_device *device,
 			"BIOS reported wrong ACPI id %d for the processor\n",
 			pr->id);
 		/* Give up, but do not abort the namespace scan. */
-		goto err;
+		goto err_clear_driver_data;
 	}
 	/*
 	 * processor_device_array is not cleared on errors to allow buggy BIOS
@@ -427,12 +427,12 @@ static int acpi_processor_add(struct acpi_device *device,
 	dev = get_cpu_device(pr->id);
 	if (!dev) {
 		result = -ENODEV;
-		goto err;
+		goto err_clear_per_cpu;
 	}
 
 	result = acpi_bind_one(dev, device);
 	if (result)
-		goto err;
+		goto err_clear_per_cpu;
 
 	pr->dev = dev;
 
@@ -443,10 +443,11 @@ static int acpi_processor_add(struct acpi_device *device,
 	dev_err(dev, "Processor driver could not be attached\n");
 	acpi_unbind_one(dev);
 
- err:
-	free_cpumask_var(pr->throttling.shared_cpu_map);
-	device->driver_data = NULL;
+ err_clear_per_cpu:
 	per_cpu(processors, pr->id) = NULL;
+ err_clear_driver_data:
+	device->driver_data = NULL;
+	free_cpumask_var(pr->throttling.shared_cpu_map);
  err_free_pr:
 	kfree(pr);
 	return result;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux