From f3dd15ad64b4d37e807ffafacb419ddd914df995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Bi=C8=99oc?= Date: Mon, 16 Dec 2024 22:09:02 +0100 Subject: [PATCH] [CMBATT] Grab the design voltage after the BIF data gets copied There was a risk of accessing invalid data as the design voltage was grabbed before the read BIF data was copied into the device extension. --- drivers/bus/acpi/cmbatt/cmbatt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/bus/acpi/cmbatt/cmbatt.c b/drivers/bus/acpi/cmbatt/cmbatt.c index 452c2242317..cff0f8afd14 100644 --- a/drivers/bus/acpi/cmbatt/cmbatt.c +++ b/drivers/bus/acpi/cmbatt/cmbatt.c @@ -280,7 +280,7 @@ CmBattVerifyStaticInfo( _In_ ULONG BatteryTag) { ACPI_BIF_DATA BifData; - ULONG DesignVoltage = DeviceExtension->BifData.DesignVoltage; + ULONG DesignVoltage; PBATTERY_INFORMATION Info = &DeviceExtension->BatteryInformation; NTSTATUS Status; @@ -293,6 +293,7 @@ CmBattVerifyStaticInfo( RtlCopyMemory(Info->Chemistry, BifData.BatteryType, 4); // FIXME: take from _BIX method: Info->CycleCount DeviceExtension->BifData = BifData; + DesignVoltage = DeviceExtension->BifData.DesignVoltage; /* Check if the power stats are reported in ampere or watts */ if (BifData.PowerUnit == ACPI_BATT_POWER_UNIT_AMPS)