From 07d38cd4c527b73e5feba38dc0bbf31303131bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Thu, 17 Jun 2021 17:52:12 +0200 Subject: [PATCH] [NTOS:PO] Do not ignore IoRegisterPlugPlayNotification return value CORE-17637 --- ntoskrnl/po/power.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/ntoskrnl/po/power.c b/ntoskrnl/po/power.c index 5f100d7a8d5..7b5b39fa818 100644 --- a/ntoskrnl/po/power.c +++ b/ntoskrnl/po/power.c @@ -403,26 +403,27 @@ PoInitSystem(IN ULONG BootPhase) /* Check if this is phase 1 init */ if (BootPhase == 1) { + NTSTATUS Status; /* Register power button notification */ - IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange, - PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES, - (PVOID)&GUID_DEVICE_SYS_BUTTON, - IopRootDeviceNode-> - PhysicalDeviceObject->DriverObject, - PopAddRemoveSysCapsCallback, - NULL, - &NotificationEntry); + Status = IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange, + PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES, + (PVOID)&GUID_DEVICE_SYS_BUTTON, + IopRootDeviceNode->PhysicalDeviceObject->DriverObject, + PopAddRemoveSysCapsCallback, + NULL, + &NotificationEntry); + if (!NT_SUCCESS(Status)) + return FALSE; /* Register lid notification */ - IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange, - PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES, - (PVOID)&GUID_DEVICE_LID, - IopRootDeviceNode-> - PhysicalDeviceObject->DriverObject, - PopAddRemoveSysCapsCallback, - NULL, - &NotificationEntry); - return TRUE; + Status = IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange, + PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES, + (PVOID)&GUID_DEVICE_LID, + IopRootDeviceNode->PhysicalDeviceObject->DriverObject, + PopAddRemoveSysCapsCallback, + NULL, + &NotificationEntry); + return NT_SUCCESS(Status); } /* Initialize the power capabilities */