[UMPNPMGR] Add checks to PNP_GetRelatedDeviceInstance

PNP_GetRelatedDeviceInstance must fail if we try to retrieve the parent or a sibling of the root device.
This commit is contained in:
Eric Kohl 2022-04-17 13:52:59 +02:00
parent 1744b01ad9
commit 7cc5163bfa

View file

@ -781,6 +781,14 @@ PNP_GetRelatedDeviceInstance(
if (!IsValidDeviceInstanceID(pDeviceID))
return CR_INVALID_DEVINST;
/* The root device does not have a parent device or sibling devices */
if ((ulRelationship == PNP_GET_PARENT_DEVICE_INSTANCE) ||
(ulRelationship == PNP_GET_SIBLING_DEVICE_INSTANCE))
{
if (IsRootDeviceInstanceID(pDeviceID))
return CR_NO_SUCH_DEVINST;
}
RtlInitUnicodeString(&PlugPlayData.TargetDeviceInstance,
pDeviceID);