ACPI: thermal: Fix a small leak in acpi_thermal_add()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 27 Sep 2023 12:37:26 +0000 (15:37 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 27 Sep 2023 12:58:14 +0000 (14:58 +0200)
Free "tz" if the "trip" allocation fails.

Fixes: 5fc2189f9335 ("ACPI: thermal: Create and populate trip points table earlier")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/thermal.c

index 10720a038846498bb4beb0465ed1e8e8d13031b4..f8a95939c88d50d52943dc7766faedca2a723974 100644 (file)
@@ -928,8 +928,10 @@ static int acpi_thermal_add(struct acpi_device *device)
        acpi_thermal_guess_offset(tz, crit_temp);
 
        trip = kcalloc(trip_count, sizeof(*trip), GFP_KERNEL);
-       if (!trip)
-               return -ENOMEM;
+       if (!trip) {
+               result = -ENOMEM;
+               goto free_memory;
+       }
 
        tz->trip_table = trip;