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

commit f0b8a1730e263400916ee4dca9dd3f0af8eab90e
Author:     Hervé Poussineau <[email protected]>
AuthorDate: Sat Oct 15 15:02:36 2022 +0200
Commit:     Hervé Poussineau <[email protected]>
CommitDate: Sat Oct 15 15:06:53 2022 +0200

    [VIDEOPRT] Correctly detach from device stack in case of failure
---
 win32ss/drivers/videoprt/videoprt.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/win32ss/drivers/videoprt/videoprt.c 
b/win32ss/drivers/videoprt/videoprt.c
index 337c3c84760..509c07288b3 100644
--- a/win32ss/drivers/videoprt/videoprt.c
+++ b/win32ss/drivers/videoprt/videoprt.c
@@ -244,9 +244,7 @@ IntVideoPortCreateAdapterDeviceObject(
     if (!NT_SUCCESS(Status))
     {
         WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 
0x%08x\n", Status);
-        IoDeleteDevice(*DeviceObject);
-        *DeviceObject = NULL;
-        return Status;
+        goto Failure;
     }
 
     if (PhysicalDeviceObject != NULL)
@@ -314,9 +312,7 @@ IntVideoPortCreateAdapterDeviceObject(
     if (!NT_SUCCESS(Status))
     {
         ERR_(VIDEOPRT, "IntCreateNewRegistryPath() failed with status 
0x%08x\n", Status);
-        IoDeleteDevice(*DeviceObject);
-        *DeviceObject = NULL;
-        return Status;
+        goto Failure;
     }
 
     IntSetupDeviceSettingsKey(DeviceExtension);
@@ -329,9 +325,7 @@ IntVideoPortCreateAdapterDeviceObject(
     if (!NT_SUCCESS(Status))
     {
         ERR_(VIDEOPRT, "IntVideoPortAddDeviceMapLink() failed with status 
0x%08x\n", Status);
-        IoDeleteDevice(*DeviceObject);
-        *DeviceObject = NULL;
-        return Status;
+        goto Failure;
     }
 
     if (DisplayNumber == 0)
@@ -340,6 +334,13 @@ IntVideoPortCreateAdapterDeviceObject(
     }
 
     return STATUS_SUCCESS;
+
+Failure:
+    if (DeviceExtension->NextDeviceObject)
+        IoDetachDevice(DeviceExtension->NextDeviceObject);
+    IoDeleteDevice(*DeviceObject);
+    *DeviceObject = NULL;
+    return Status;
 }
 
 

Reply via email to