Skip to contentSkip to conversation

memory leakages in drivers/acpi/thermal.c

PATCH New Vasily Averin 1 participant 1 message Apr 9, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memory leakages in drivers/acpi/thermal.c

acpi_thermal_write_trip_points() and acpi_thermal_add() do not call kfree() for allocated memory on the error path.

Thank you,
Vasily Averin

SWsoft Virtuozzo/OpenVZ Linux kernel team

drivers/acpi/thermal.c +4 -2
@@ -942,8 +942,10 @@ acpi_thermal_write_trip_points(struct fi
 	memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN);
 
 	active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL);
-	if (!active)
+	if (!active) {
+		kfree(limit_string);
 		return_VALUE(-ENOMEM);
+	}
 
 	if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) {
 		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n"));
@@ -1342,7 +1344,7 @@ static int acpi_thermal_add(struct acpi_
 
 	result = acpi_thermal_add_fs(device);
 	if (result)
-		return_VALUE(result);
+		goto end;
 
 	init_timer(&tz->timer);