From 1f33d186878b707d956f07607b1f4b1b6063d543 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Fri, 17 Feb 2012 05:04:49 +0000 Subject: [PATCH] Don't install FV protocol on the corrupt FV image. Signed-off-by: lgao4 Reviewed-by: rsun3 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13020 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/FwVol/FwVol.c | 31 ++++++++++++++--------- MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c | 9 +------ MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h | 19 +------------- 3 files changed, 21 insertions(+), 38 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c index 07cbbb94df..66b7673872 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c @@ -3,7 +3,7 @@ Layers on top of Firmware Block protocol to produce a file abstraction of FV based files. -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -630,17 +630,24 @@ NotifyFwVolBlock ( FvDevice->FwVolHeader = FwVolHeader; FvDevice->Fv.ParentHandle = Fvb->ParentHandle; FvDevice->IsFfs3Fv = CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem3Guid); - - // - // Install an New FV protocol on the existing handle - // - Status = CoreInstallProtocolInterface ( - &Handle, - &gEfiFirmwareVolume2ProtocolGuid, - EFI_NATIVE_INTERFACE, - &FvDevice->Fv - ); - ASSERT_EFI_ERROR (Status); + + if (!EFI_ERROR (FvCheck (FvDevice))) { + // + // Install an New FV protocol on the existing handle + // + Status = CoreInstallProtocolInterface ( + &Handle, + &gEfiFirmwareVolume2ProtocolGuid, + EFI_NATIVE_INTERFACE, + &FvDevice->Fv + ); + ASSERT_EFI_ERROR (Status); + } else { + // + // Free FvDevice Buffer for the corrupt FV image. + // + CoreFreePool (FvDevice); + } } } diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c b/MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c index 4d84dbd895..0a89e70761 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolAttrib.c @@ -1,7 +1,7 @@ /** @file Implements get/set firmware volume attributes -Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -41,13 +41,6 @@ FvGetVolumeAttributes ( FvDevice = FV_DEVICE_FROM_THIS (This); Fvb = FvDevice->Fvb; - if (FvDevice->CachedFv == NULL) { - Status = FvCheck (FvDevice); - if (EFI_ERROR (Status)) { - return Status; - } - } - // // First get the Firmware Volume Block Attributes // diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h b/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h index a614b93d1b..31d15120eb 100644 --- a/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h +++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolDriver.h @@ -2,7 +2,7 @@ Firmware File System protocol. Layers on top of Firmware Block protocol to produce a file abstraction of FV based files. -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -423,21 +423,4 @@ GetFwVolHeader ( OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader ); - - -/** - Check if an FV is consistent and allocate cache for it. - - @param FvDevice A pointer to the FvDevice to be checked. - - @retval EFI_OUT_OF_RESOURCES No enough buffer could be allocated. - @retval EFI_SUCCESS FV is consistent and cache is allocated. - @retval EFI_VOLUME_CORRUPTED File system is corrupted. - -**/ -EFI_STATUS -FvCheck ( - IN OUT FV_DEVICE *FvDevice - ); - #endif -- 2.39.2