https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4be3bc682dbffb845318b…
commit 4be3bc682dbffb845318b868eb3f9de1d8ece1c5
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Sat Oct 9 15:59:58 2021 -0400
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Wed Oct 27 19:27:32 2021 -0400
[SACDRV] Fix uninitialized variable usage.
Powered by clang-cl.
---
drivers/sac/driver/data.c | 41 ++++++++++++++++++++++-------------------
drivers/sac/driver/sacdrv.h | 1 +
2 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/drivers/sac/driver/data.c b/drivers/sac/driver/data.c
index d7f1ae09d09..face230f688 100644
--- a/drivers/sac/driver/data.c
+++ b/drivers/sac/driver/data.c
@@ -153,27 +153,29 @@ FreeDeviceData(IN PDEVICE_OBJECT DeviceObject)
/* Get the device extension and see how far we had gotten */
DeviceExtension = (PSAC_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
- if ((GlobalDataInitialized) && (DeviceExtension->Initialized))
+ if (!(GlobalDataInitialized) || !(DeviceExtension->Initialized))
{
- /* Attempt to rundown while holding the lock */
+ goto Exit;
+ }
+
+ /* Attempt to rundown while holding the lock */
+ KeAcquireSpinLock(&DeviceExtension->Lock, &OldIrql);
+ while (DeviceExtension->RundownInProgress)
+ {
+ SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC FreeDeviceData: Waiting....\n");
+
+ /* Initiate and wait for rundown */
+ KeInitializeEvent(&DeviceExtension->RundownEvent, SynchronizationEvent,
0);
+ KeReleaseSpinLock(&DeviceExtension->Lock, OldIrql);
+ Status = KeWaitForSingleObject(&DeviceExtension->RundownEvent,
+ Executive,
+ KernelMode,
+ FALSE,
+ NULL);
+ ASSERT(Status == STATUS_SUCCESS);
+
+ /* Re-acquire the lock and check if rundown is done */
KeAcquireSpinLock(&DeviceExtension->Lock, &OldIrql);
- while (DeviceExtension->RundownInProgress)
- {
- SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC FreeDeviceData: Waiting....\n");
-
- /* Initiate and wait for rundown */
- KeInitializeEvent(&DeviceExtension->RundownEvent,
SynchronizationEvent, 0);
- KeReleaseSpinLock(&DeviceExtension->Lock, OldIrql);
- Status = KeWaitForSingleObject(&DeviceExtension->RundownEvent,
- Executive,
- KernelMode,
- FALSE,
- NULL);
- ASSERT(Status == STATUS_SUCCESS);
-
- /* Re-acquire the lock and check if rundown is done */
- KeAcquireSpinLock(&DeviceExtension->Lock, &OldIrql);
- }
}
/* Now set the rundown flag while we cancel the timer */
@@ -205,6 +207,7 @@ FreeDeviceData(IN PDEVICE_OBJECT DeviceObject)
KeAcquireSpinLock(&DeviceExtension->Lock, &OldIrql);
DeviceExtension->Initialized = FALSE;
KeReleaseSpinLock(&DeviceExtension->Lock, OldIrql);
+Exit:
SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC FreeDeviceData: Exiting.\n");
}
diff --git a/drivers/sac/driver/sacdrv.h b/drivers/sac/driver/sacdrv.h
index 0280b6c9d1c..9c44671985f 100644
--- a/drivers/sac/driver/sacdrv.h
+++ b/drivers/sac/driver/sacdrv.h
@@ -74,6 +74,7 @@
{ \
if (!VerifyEventWaitable(Attributes->x, &Object, &WaitObject)) \
{ \
+ Status = STATUS_INVALID_HANDLE; \
goto FailChannel; \
} \
Channel->x = Attributes->x; \