Skip to content

Commit

Permalink
fix: Unregister callback on exit boot services
Browse files Browse the repository at this point in the history
The PlatformBm library is not used in a runtime driver.
Need to unregister the status code to prevent use during runtime.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Tested-by: Jake Garver <jake@nvidia.com>
Reviewed-by: Jake Garver <jake@nvidia.com>
  • Loading branch information
jbrasen authored and jgarver committed Jan 14, 2025
1 parent 4b2b87c commit b720a12
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Silicon/NVIDIA/Library/PlatformBootManagerLib/PlatformBm.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file
Implementation for PlatformBootManagerLib library class interfaces.
SPDX-FileCopyrightText: Copyright (c) 2020-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-FileCopyrightText: Copyright (c) 2020-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copyright (C) 2015-2016, Red Hat, Inc.
Copyright (c) 2014, ARM Ltd. All rights reserved.<BR>
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
Expand Down Expand Up @@ -102,6 +102,7 @@ STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
};

STATIC PLATFORM_CONFIGURATION_DATA CurrentPlatformConfigData;
EFI_RSC_HANDLER_PROTOCOL *mRscHandler = NULL;

/**
Check if the handle satisfies a particular condition.
Expand Down Expand Up @@ -1995,6 +1996,14 @@ SingleBootStatusCodeCallback (
CpuDeadLoop ();
}

if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) &&
(Value == (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)))
{
if (mRscHandler != NULL) {
mRscHandler->Unregister (SingleBootStatusCodeCallback);
}
}

return EFI_SUCCESS;
}

Expand Down Expand Up @@ -2023,7 +2032,6 @@ PlatformBootManagerBeforeConsole (
EFI_INPUT_KEY ShellKey;
BOOLEAN SingleBoot;
EFI_GUID *SingleBootAppGuid;
EFI_RSC_HANDLER_PROTOCOL *RscHandler;

if (FeaturePcdGet (PcdMemoryTestsSupported)) {
// Attempt to delete variable to prevent forced allocation at targeted address.
Expand Down Expand Up @@ -2190,10 +2198,10 @@ PlatformBootManagerBeforeConsole (
LoadOptionTypeBoot
);

Status = gBS->LocateProtocol (&gEfiRscHandlerProtocolGuid, NULL, (VOID **)&RscHandler);
Status = gBS->LocateProtocol (&gEfiRscHandlerProtocolGuid, NULL, (VOID **)&mRscHandler);
ASSERT_EFI_ERROR (Status);
if (!EFI_ERROR (Status)) {
RscHandler->Register (SingleBootStatusCodeCallback, TPL_CALLBACK);
mRscHandler->Register (SingleBootStatusCodeCallback, TPL_CALLBACK);
}
}

Expand Down

0 comments on commit b720a12

Please sign in to comment.