Fix memory leak issues in BiosSnp module.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Elvin Li <elvin.li@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15671 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Elvin Li 2014-07-23 02:12:37 +00:00 committed by li-elvin
parent 1c50db8ada
commit 9f6c5db258
2 changed files with 14 additions and 3 deletions

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 1999 - 2012, Intel Corporation. All rights reserved.<BR> Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions are licensed and made available under the terms and conditions
@ -1260,6 +1260,11 @@ Undi16SimpleNetworkLoadUndi (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
//
// Free resources allocated in LaunchBaseCode
//
Undi16SimpleNetworkUnloadUndi (SimpleNetworkDevice);
} }
return EFI_NOT_FOUND; return EFI_NOT_FOUND;

View File

@ -1,7 +1,7 @@
/** @file /** @file
Helper Routines that use a PXE-enabled NIC option ROM. Helper Routines that use a PXE-enabled NIC option ROM.
Copyright (c) 1999 - 2010, Intel Corporation. All rights reserved.<BR> Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions are licensed and made available under the terms and conditions
@ -743,6 +743,11 @@ LaunchBaseCode (
InOutRegs.X.AX) 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, "Now returned from the UNDI code\n\r"));
DEBUG ((DEBUG_NET, "After the call, we have...\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); Pxe = (PXE_T *)(UINTN)((UndiLoaderTable->PXEptr.Segment << 4) + UndiLoaderTable->PXEptr.Offset);
SimpleNetworkDevice->Nii.Id = (UINT64)(UINTN) Pxe; SimpleNetworkDevice->Nii.Id = (UINT64)(UINTN) Pxe;
gBS->FreePool (Buffer);
// //
// FreePool (Buffer);
// paranoia - make sure a valid !PXE structure // paranoia - make sure a valid !PXE structure
// //
if (CompareMem (Pxe->Signature, PXE_SIG, sizeof Pxe->Signature) != 0) { if (CompareMem (Pxe->Signature, PXE_SIG, sizeof Pxe->Signature) != 0) {