From 9f6c5db258aee82f586b5b2858d0d979e89c916b Mon Sep 17 00:00:00 2001 From: Elvin Li Date: Wed, 23 Jul 2014 02:12:37 +0000 Subject: [PATCH] Fix memory leak issues in BiosSnp module. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Elvin Li Reviewed-by: Jeff Fan git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15671 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Csm/BiosThunk/Snp16Dxe/BiosSnp16.c | 7 ++++++- IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Misc.c | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16.c b/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16.c index 744a7e3453..05254100f1 100644 --- a/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16.c +++ b/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/BiosSnp16.c @@ -1,6 +1,6 @@ /** @file -Copyright (c) 1999 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions @@ -1260,6 +1260,11 @@ Undi16SimpleNetworkLoadUndi ( if (!EFI_ERROR (Status)) { return EFI_SUCCESS; } + + // + // Free resources allocated in LaunchBaseCode + // + Undi16SimpleNetworkUnloadUndi (SimpleNetworkDevice); } return EFI_NOT_FOUND; diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Misc.c b/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Misc.c index 0b3543e12c..243048c551 100644 --- a/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Misc.c +++ b/IntelFrameworkModulePkg/Csm/BiosThunk/Snp16Dxe/Misc.c @@ -1,7 +1,7 @@ /** @file Helper Routines that use a PXE-enabled NIC option ROM. -Copyright (c) 1999 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions @@ -743,6 +743,11 @@ LaunchBaseCode ( InOutRegs.X.AX) ); + if ((UndiLoaderTable->Status != 0) || (InOutRegs.X.AX != PXENV_EXIT_SUCCESS)) { + DEBUG ((DEBUG_NET, "LaunchBaseCode exits with error, RomAddress = 0x%X\n\r", RomAddress)); + return EFI_ABORTED; + } + DEBUG ((DEBUG_NET, "Now returned from the UNDI code\n\r")); DEBUG ((DEBUG_NET, "After the call, we have...\n\r")); @@ -755,8 +760,9 @@ LaunchBaseCode ( Pxe = (PXE_T *)(UINTN)((UndiLoaderTable->PXEptr.Segment << 4) + UndiLoaderTable->PXEptr.Offset); SimpleNetworkDevice->Nii.Id = (UINT64)(UINTN) Pxe; + gBS->FreePool (Buffer); + // - // FreePool (Buffer); // paranoia - make sure a valid !PXE structure // if (CompareMem (Pxe->Signature, PXE_SIG, sizeof Pxe->Signature) != 0) {