fix some memory leaks and crashes, according to Tiano

Signed-off-by: Slice <sergey.slice@gmail.com>
This commit is contained in:
Slice 2023-09-05 22:20:35 +03:00
parent 7adb640a42
commit b91c9dec6f
7 changed files with 2001 additions and 1834 deletions

View File

@ -2470,7 +2470,7 @@ GetDriverNameWorker (
BestLanguage, BestLanguage,
DriverName DriverName
); );
FreePool(BestLanguage); // FreePool(BestLanguage); // it was not allocated
return Status; return Status;
} }

View File

@ -699,6 +699,10 @@ CoreLocateHandleBuffer (
*NumberHandles = BufferSize / sizeof(EFI_HANDLE); *NumberHandles = BufferSize / sizeof(EFI_HANDLE);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
*NumberHandles = 0; *NumberHandles = 0;
if (*Buffer != NULL) {
CoreFreePool (*Buffer);
*Buffer = NULL;
}
} }
return Status; return Status;

View File

@ -496,13 +496,13 @@ LoadOpRomImage (
Indicator = RomPcir->Indicator; Indicator = RomPcir->Indicator;
RomImageSize = RomImageSize + RomPcir->ImageLength * 512; RomImageSize = RomImageSize + RomPcir->ImageLength * 512;
RomBarOffset = RomBarOffset + RomPcir->ImageLength * 512; RomBarOffset = RomBarOffset + RomPcir->ImageLength * 512;
} while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) < RomSize)); } while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) < RomSize) && (RomImageSize > 0));
// //
// Some Legacy Cards do not report the correct ImageLength so used the maximum // Some Legacy Cards do not report the correct ImageLength so used the maximum
// of the legacy length and the PCIR Image Length // of the legacy length and the PCIR Image Length
// //
if (CodeType == PCI_CODE_TYPE_PCAT_IMAGE) { if ((RomImageSize > 0) && (CodeType == PCI_CODE_TYPE_PCAT_IMAGE)) {
RomImageSize = MAX (RomImageSize, LegacyImageLength); RomImageSize = MAX (RomImageSize, LegacyImageLength);
} }

View File

@ -1,7 +1,7 @@
/** @file /** @file
Locate handle functions Locate handle functions
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
@ -693,6 +693,10 @@ CoreLocateHandleBuffer (
*NumberHandles = BufferSize / sizeof(EFI_HANDLE); *NumberHandles = BufferSize / sizeof(EFI_HANDLE);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
*NumberHandles = 0; *NumberHandles = 0;
if (*Buffer != NULL) {
CoreFreePool (*Buffer);
*Buffer = NULL;
}
} }
return Status; return Status;

View File

@ -12,7 +12,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _DXE_CORE_PERFORMANCE_LIB_INTERNAL_H_ #ifndef _DXE_CORE_PERFORMANCE_LIB_INTERNAL_H_
#define _DXE_CORE_PERFORMANCE_LIB_INTERNAL_H_ #define _DXE_CORE_PERFORMANCE_LIB_INTERNAL_H_
#include <PiDxe.h> #include <PiDxe.h>
#include <Guid/Performance.h> #include <Guid/Performance.h>
@ -65,12 +64,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
CreatePerformanceMeasurement( CreatePerformanceMeasurement (
IN CONST VOID *CallerIdentifier, OPTIONAL IN CONST VOID *CallerIdentifier OPTIONAL,
IN CONST VOID *Guid, OPTIONAL IN CONST VOID *Guid OPTIONAL,
IN CONST CHAR8 *String, OPTIONAL IN CONST CHAR8 *String OPTIONAL,
IN UINT64 TimeStamp, OPTIONAL IN UINT64 TimeStamp OPTIONAL,
IN UINT64 Address, OPTIONAL IN UINT64 Address OPTIONAL,
IN UINT32 Identifier, IN UINT32 Identifier,
IN PERF_MEASUREMENT_ATTRIBUTE Attribute IN PERF_MEASUREMENT_ATTRIBUTE Attribute
); );

View File

@ -93,6 +93,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE 42 #define SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE 42
#define SMBIOS_TYPE_TPM_DEVICE 43 #define SMBIOS_TYPE_TPM_DEVICE 43
#define SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION 44 #define SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION 44
#define SMBIOS_TYPE_FIRMWARE_INVENTORY_INFORMATION 45
#define SMBIOS_TYPE_STRING_PROPERTY_INFORMATION 46
/// ///
/// Inactive type is added from SMBIOS 2.2. Reference SMBIOS 2.6, chapter 3.3.43. /// Inactive type is added from SMBIOS 2.2. Reference SMBIOS 2.6, chapter 3.3.43.
@ -812,7 +814,24 @@ typedef enum {
ProcessorUpgradeSocketBGA1528 = 0x3C, ProcessorUpgradeSocketBGA1528 = 0x3C,
ProcessorUpgradeSocketLGA4189 = 0x3D, ProcessorUpgradeSocketLGA4189 = 0x3D,
ProcessorUpgradeSocketLGA1200 = 0x3E, ProcessorUpgradeSocketLGA1200 = 0x3E,
ProcessorUpgradeSocketLGA4677 = 0x3F ProcessorUpgradeSocketLGA4677 = 0x3F,
ProcessorUpgradeSocketLGA1700 = 0x40,
ProcessorUpgradeSocketBGA1744 = 0x41,
ProcessorUpgradeSocketBGA1781 = 0x42,
ProcessorUpgradeSocketBGA1211 = 0x43,
ProcessorUpgradeSocketBGA2422 = 0x44,
ProcessorUpgradeSocketLGA1211 = 0x45,
ProcessorUpgradeSocketLGA2422 = 0x46,
ProcessorUpgradeSocketLGA5773 = 0x47,
ProcessorUpgradeSocketBGA5773 = 0x48,
ProcessorUpgradeSocketAM5 = 0x49,
ProcessorUpgradeSocketSP5 = 0x4A,
ProcessorUpgradeSocketSP6 = 0x4B,
ProcessorUpgradeSocketBGA883 = 0x4C,
ProcessorUpgradeSocketBGA1190 = 0x4D,
ProcessorUpgradeSocketBGA4129 = 0x4E,
ProcessorUpgradeSocketLGA4710 = 0x4F,
ProcessorUpgradeSocketLGA7529 = 0x50
} PROCESSOR_UPGRADE; } PROCESSOR_UPGRADE;
/// ///