From 300dada916aa9492d5fe52693e9d6fd84adccdf3 Mon Sep 17 00:00:00 2001 From: Khalid Ali Date: Thu, 25 Dec 2025 16:24:47 +0000 Subject: [PATCH] MdeModulePkg/Core: Make PPI services spec complaint The documentation of InstallPpi() and NotifyPpi() in both the spec and function comment indicate to return EFI_OUT_OF_RESOURCES if memory allocation fails. However, the implementation of those two services assert if memory allocation fails. This is a mismatch between what the function expected to return and what actually returns. Fix this by returning EFI_OUT_OF_RESOURCES if memory allocation fails, so the code matches the documentation and comply with the spec. It is expected service consumers(callers of these functions) to handle failures appriciately. Signed-off-by: Khalid Ali --- MdeModulePkg/Core/Pei/Ppi/Ppi.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/MdeModulePkg/Core/Pei/Ppi/Ppi.c index df2cb9221d..ad77481b3b 100644 --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c @@ -493,7 +493,11 @@ InternalPeiInstallPpi ( TempPtr = AllocateZeroPool ( sizeof (PEI_PPI_LIST_POINTERS) * (PpiListPointer->MaxCount + PPI_GROWTH_STEP) ); - ASSERT (TempPtr != NULL); + if (TempPtr == NULL) { + ASSERT (TempPtr != NULL); + return EFI_OUT_OF_RESOURCES; + } + CopyMem ( TempPtr, PpiListPointer->PpiPtrs, @@ -782,7 +786,11 @@ InternalPeiNotifyPpi ( TempPtr = AllocateZeroPool ( sizeof (PEI_PPI_LIST_POINTERS) * (CallbackNotifyListPointer->MaxCount + CALLBACK_NOTIFY_GROWTH_STEP) ); - ASSERT (TempPtr != NULL); + if (TempPtr == NULL) { + ASSERT (TempPtr != NULL); + return EFI_OUT_OF_RESOURCES; + } + CopyMem ( TempPtr, CallbackNotifyListPointer->NotifyPtrs, @@ -803,7 +811,11 @@ InternalPeiNotifyPpi ( TempPtr = AllocateZeroPool ( sizeof (PEI_PPI_LIST_POINTERS) * (DispatchNotifyListPointer->MaxCount + DISPATCH_NOTIFY_GROWTH_STEP) ); - ASSERT (TempPtr != NULL); + if (TempPtr == NULL) { + ASSERT (TempPtr != NULL); + return EFI_OUT_OF_RESOURCES; + } + CopyMem ( TempPtr, DispatchNotifyListPointer->NotifyPtrs,