[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.
This commit is contained in:
George Bișoc 2024-12-16 22:09:02 +01:00
parent ea8315ba56
commit f3dd15ad64
No known key found for this signature in database
GPG key ID: 688C4FBE25D7DEF6

View file

@ -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)