diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 055f9351d1d..f288d263457 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -3507,6 +3507,10 @@ IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, return STATUS_INVALID_PARAMETER; } + if (!IopIsValidPhysicalDeviceObject(DeviceObject)) + return STATUS_INVALID_DEVICE_REQUEST; + DeviceNode = IopGetDeviceNode(DeviceObject); + /* * Calculate the length of the base key name. This is the full * name for driver key or the name excluding "Device Parameters" @@ -3527,9 +3531,6 @@ IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, } else { - if (!IopIsValidPhysicalDeviceObject(DeviceObject)) - return STATUS_INVALID_DEVICE_REQUEST; - DeviceNode = IopGetDeviceNode(DeviceObject); KeyNameLength += sizeof(EnumKeyName) - sizeof(UNICODE_NULL) + DeviceNode->InstancePath.Length; }