https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f3dd15ad64b4d37e807ffafacb419ddd914df995

commit f3dd15ad64b4d37e807ffafacb419ddd914df995
Author:     George Bișoc <george.bi...@reactos.org>
AuthorDate: Mon Dec 16 22:09:02 2024 +0100
Commit:     George Bișoc <george.bi...@reactos.org>
CommitDate: Mon Dec 16 22:09:02 2024 +0100

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

Reply via email to