Skip to content

Commit 05ae940

Browse files
committed
[COMPBATT] Free device-related memory only if we failed
Otherwise, we just inserted in the BatteryList this device, and we will probably crash later when accessing it.
1 parent 2323dbc commit 05ae940

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/bus/acpi/compbatt/comppnp.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,11 @@ CompBattAddNewBattery(IN PUNICODE_STRING BatteryName,
199199
Status);
200200
}
201201

202-
/* Free the battery data */
203-
ExFreePool(BatteryData);
202+
if (!NT_SUCCESS(Status))
203+
{
204+
/* Free the battery data */
205+
ExFreePool(BatteryData);
206+
}
204207
}
205208
else
206209
{

0 commit comments

Comments
 (0)