From: Star Zeng Date: Fri, 13 Apr 2018 09:55:14 +0000 (+0800) Subject: SignedCapsulePkg SystemFirmwareUpdateDxe: Fix failure caused by d69d922 X-Git-Tag: edk2-stable201903~1897 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=665bfd41ac32b364201c07dc1c5434432730c034;hp=b85b20fba42e25ff658ed1a470250d530c189027 SignedCapsulePkg SystemFirmwareUpdateDxe: Fix failure caused by d69d922 d69d9227d046211265de1fab5580c50a65944614 caused system firmware update failure. It is because FindMatchingFmpHandles() is expected to return handles matched, but the function returns all handles found. This patch is to fix the issue. This patch also assigns mSystemFmpPrivate->Handle for "case 1:" path in case the Handle is needed by other place in future. Cc: Michael D Kinney Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng Reviewed-by: Jiewen Yao Reviewed-by: Michael D Kinney --- diff --git a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c index d0b1c9913c..fa0c5f03ff 100644 --- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c +++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c @@ -602,6 +602,7 @@ FindMatchingFmpHandles ( ) { EFI_STATUS Status; + UINTN TempHandleCount; EFI_HANDLE *HandleBuffer; UINTN Index; UINTN Index2; @@ -613,20 +614,20 @@ FindMatchingFmpHandles ( BOOLEAN MatchFound; *HandleCount = 0; + TempHandleCount = 0; HandleBuffer = NULL; Status = gBS->LocateHandleBuffer ( ByProtocol, ProtocolGuid, NULL, - HandleCount, + &TempHandleCount, &HandleBuffer ); if (EFI_ERROR (Status)) { - *HandleCount = 0; return NULL; } - for (Index = 0; Index < *HandleCount; Index++) { + for (Index = 0; Index < TempHandleCount; Index++) { OriginalFmpImageInfoBuf = GetFmpImageDescriptors ( HandleBuffer[Index], ProtocolGuid, @@ -657,12 +658,21 @@ FindMatchingFmpHandles ( // FmpImageInfoBuf = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *)(((UINT8 *)FmpImageInfoBuf) + DescriptorSize); } - if (!MatchFound) { - HandleBuffer[Index] = NULL; + if (MatchFound) { + HandleBuffer[*HandleCount] = HandleBuffer[Index]; + (*HandleCount)++; } FreePool (OriginalFmpImageInfoBuf); } + + if ((*HandleCount) == 0) { + // + // No any matching handle. + // + FreePool (HandleBuffer); + return NULL; + } return HandleBuffer; } @@ -801,6 +811,7 @@ SystemFirmwareUpdateMainDxe ( // Install System FMP protocol onto handle with matching FMP Protocol // DEBUG ((DEBUG_INFO, "SystemFirmwareUpdateDxe: Install System FMP onto matching FMP handle\n")); + mSystemFmpPrivate->Handle = HandleBuffer[0]; Status = gBS->InstallMultipleProtocolInterfaces ( &HandleBuffer[0], &gSystemFmpProtocolGuid,