[NTOS]: Addendums to r74491 and r74493:

- Free the FullServiceName buffer if PnpRootCreateDevice failed (erroneously committed in r74494, see pnpmgr.c line 1080);
- No need to close InstanceHandle if the IopCreateDeviceKeyPath call failed, since in this case the registry handle wasn't opened. CORE-13207
- Don't assert on Buffer allocation but return a proper failure code in case of failure. CORE-13208
These are suggestions from Serge Gautherie + Lesan Ilie.

- Add a forgotten ZwClose call in the success code path of IopCreateDeviceKeyPath in IopQueryDeviceCapabilities (by me).

svn path=/trunk/; revision=74495
This commit is contained in:
Hermès Bélusca-Maïto
2017-05-08 00:58:45 +00:00
parent 32b595761c
commit 55bf6ea8ff
2 changed files with 6 additions and 2 deletions
+4 -1
View File
@@ -899,7 +899,10 @@ IopInitializeBuiltinDriver(IN PLDR_DATA_TABLE_ENTRY BootLdrEntry)
InbvIndicateProgress();
Buffer = ExAllocatePool(PagedPool, ModuleName->Length + sizeof(UNICODE_NULL));
ASSERT(Buffer);
if (Buffer == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlCopyMemory(Buffer, ModuleName->Buffer, ModuleName->Length);
Buffer[ModuleName->Length / sizeof(WCHAR)] = UNICODE_NULL;
+2 -1
View File
@@ -892,6 +892,8 @@ IopQueryDeviceCapabilities(PDEVICE_NODE DeviceNode,
&DeviceCaps->UINumber,
sizeof(ULONG));
}
ZwClose(InstanceKey);
}
return Status;
@@ -1086,7 +1088,6 @@ IopCreateDeviceNode(PDEVICE_NODE ParentNode,
Status = IopCreateDeviceKeyPath(&Node->InstancePath, REG_OPTION_VOLATILE, &InstanceHandle);
if (!NT_SUCCESS(Status))
{
ZwClose(InstanceHandle);
ExFreePool(FullServiceName.Buffer);
ExFreePoolWithTag(Node, TAG_IO_DEVNODE);
return Status;