[VIDEOPRT] Correctly detach from device stack in case of failure

This commit is contained in:
Hervé Poussineau 2022-10-15 15:02:36 +02:00
parent 13868ee0e8
commit f0b8a1730e

View file

@ -244,9 +244,7 @@ IntVideoPortCreateAdapterDeviceObject(
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status); WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status);
IoDeleteDevice(*DeviceObject); goto Failure;
*DeviceObject = NULL;
return Status;
} }
if (PhysicalDeviceObject != NULL) if (PhysicalDeviceObject != NULL)
@ -314,9 +312,7 @@ IntVideoPortCreateAdapterDeviceObject(
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ERR_(VIDEOPRT, "IntCreateNewRegistryPath() failed with status 0x%08x\n", Status); ERR_(VIDEOPRT, "IntCreateNewRegistryPath() failed with status 0x%08x\n", Status);
IoDeleteDevice(*DeviceObject); goto Failure;
*DeviceObject = NULL;
return Status;
} }
IntSetupDeviceSettingsKey(DeviceExtension); IntSetupDeviceSettingsKey(DeviceExtension);
@ -329,9 +325,7 @@ IntVideoPortCreateAdapterDeviceObject(
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ERR_(VIDEOPRT, "IntVideoPortAddDeviceMapLink() failed with status 0x%08x\n", Status); ERR_(VIDEOPRT, "IntVideoPortAddDeviceMapLink() failed with status 0x%08x\n", Status);
IoDeleteDevice(*DeviceObject); goto Failure;
*DeviceObject = NULL;
return Status;
} }
if (DisplayNumber == 0) if (DisplayNumber == 0)
@ -340,6 +334,13 @@ IntVideoPortCreateAdapterDeviceObject(
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;
Failure:
if (DeviceExtension->NextDeviceObject)
IoDetachDevice(DeviceExtension->NextDeviceObject);
IoDeleteDevice(*DeviceObject);
*DeviceObject = NULL;
return Status;
} }