diff --git a/ntoskrnl/io/pnpmgr/devaction.c b/ntoskrnl/io/pnpmgr/devaction.c index b98c2145723..18a435f3a38 100644 --- a/ntoskrnl/io/pnpmgr/devaction.c +++ b/ntoskrnl/io/pnpmgr/devaction.c @@ -1396,6 +1396,14 @@ IopSetServiceEnumData( goto done; } + Status = RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING, + &ServiceName, + &DeviceNode->ServiceName); + if (!NT_SUCCESS(Status)) + { + goto done; + } + RtlInitUnicodeString(&EnumKeyName, L"Enum"); Status = IopCreateRegistryKeyEx(&ServiceEnumKey, ServiceKey, @@ -1480,10 +1488,6 @@ IopSetServiceEnumData( sizeof(NextInstance)); } - RtlDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING, - &ServiceName, - &DeviceNode->ServiceName); - done: if (ServiceEnumKey != NULL) ZwClose(ServiceEnumKey);