From 55065d3b519eb02248c11acf354fe5261067e7d6 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Thu, 28 Apr 2022 22:16:37 +0900 Subject: [PATCH] [NTOS:PNP] Fix GCC build (ignoring return value) (#4473) [NTOS:PNP] Fix GCC build (ignoring return value) Properly handle RtlDuplicateUnicodeString return status. Addendum to de316477. Thanks to @HBelusca and @Doug-Lyons. --- ntoskrnl/io/pnpmgr/plugplay.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ntoskrnl/io/pnpmgr/plugplay.c b/ntoskrnl/io/pnpmgr/plugplay.c index 46093b252b5..e3412c4cfa3 100644 --- a/ntoskrnl/io/pnpmgr/plugplay.c +++ b/ntoskrnl/io/pnpmgr/plugplay.c @@ -245,8 +245,14 @@ IopInitializeDevice( } /* Set the device instance of the device node */ - RtlDuplicateUnicodeString(0, &DeviceInstance, &DeviceNode->InstancePath); - + Status = RtlDuplicateUnicodeString(0, &DeviceInstance, &DeviceNode->InstancePath); + if (!NT_SUCCESS(Status)) + { + DPRINT1("RtlDuplicateUnicodeString() failed (Status 0x%08lx)\n", Status); + IopFreeDeviceNode(DeviceNode); + IoDeleteDevice(DeviceObject); + goto done; + } /* Insert as a root enumerated device node */ PiInsertDevNode(DeviceNode, IopRootDeviceNode);