https://git.reactos.org/?p=reactos.git;a=commitdiff;h=05ae94092e6bf40344a5f…
commit 05ae94092e6bf40344a5ffb4dbd58121a853668e
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Wed Nov 20 18:59:20 2024 +0100
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Wed Nov 20 21:47:13 2024 +0100
[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.
---
drivers/bus/acpi/compbatt/comppnp.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/bus/acpi/compbatt/comppnp.c b/drivers/bus/acpi/compbatt/comppnp.c
index 1083ae7f866..61b87736758 100644
--- a/drivers/bus/acpi/compbatt/comppnp.c
+++ b/drivers/bus/acpi/compbatt/comppnp.c
@@ -199,8 +199,11 @@ CompBattAddNewBattery(IN PUNICODE_STRING BatteryName,
Status);
}
- /* Free the battery data */
- ExFreePool(BatteryData);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Free the battery data */
+ ExFreePool(BatteryData);
+ }
}
else
{