From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5726021EA15AC for ; Fri, 13 Apr 2018 03:06:22 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Apr 2018 03:06:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,444,1517904000"; d="scan'208";a="33390515" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by orsmga008.jf.intel.com with ESMTP; 13 Apr 2018 03:06:20 -0700 From: Star Zeng To: edk2-devel@lists.01.org Cc: Star Zeng , Michael D Kinney , Jiewen Yao Date: Fri, 13 Apr 2018 18:06:18 +0800 Message-Id: <1523613978-121936-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [PATCH] SignedCapsulePkg SystemFirmwareUpdateDxe: Fix failure caused by d69d922 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Apr 2018 10:06:22 -0000 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 --- .../SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c index d0b1c9913ca8..fa0c5f03ffdd 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, -- 2.7.0.windows.1