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 {