From: jljusten Date: Mon, 24 Nov 2008 00:30:53 +0000 (+0000) Subject: Resolve a bug where the initial ReadEdidData 'for' loop would loop X-Git-Tag: edk2-stable201903~19557 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=6f716497dee8dcc8eea249e3136793678cf6ad59;p=mirror_edk2.git Resolve a bug where the initial ReadEdidData 'for' loop would loop infinitely, since the Index variable was declared as UINT8, and 'EDID_BLOCK_SIZE * 2' is 256. In the EFI_SUCCESS return path of CirrusLogic5430VideoModeSetup, check that 'EdidOverrideDataBlock' has been allocated before attempting to free this memory. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6688 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/OptionRomPkg/CirrusLogic5430Dxe/Edid.c b/OptionRomPkg/CirrusLogic5430Dxe/Edid.c index 76a74ccf5e..73999e3f15 100644 --- a/OptionRomPkg/CirrusLogic5430Dxe/Edid.c +++ b/OptionRomPkg/CirrusLogic5430Dxe/Edid.c @@ -112,7 +112,7 @@ ReadEdidData ( UINTN *EdidSize ) { - UINT8 Index; + UINTN Index; UINT8 EdidData[EDID_BLOCK_SIZE * 2]; UINT8 *ValidEdid; UINT64 Signature; @@ -397,7 +397,7 @@ CirrusLogic5430VideoModeSetup ( // If EDID Override data doesn't exist or EFI_EDID_OVERRIDE_DONT_OVERRIDE returned, // read EDID information through I2C Bus // - if (ReadEdidData (Private, &EdidDiscoveredDataBlock, &EdidDiscoveredDataSize) == EFI_SUCCESS) {; + if (ReadEdidData (Private, &EdidDiscoveredDataBlock, &EdidDiscoveredDataSize) == EFI_SUCCESS) { Private->EdidDiscovered.SizeOfEdid = (UINT32) EdidDiscoveredDataSize; Private->EdidDiscovered.Edid = (UINT8 *) AllocateCopyPool ( EdidDiscoveredDataSize, @@ -509,7 +509,10 @@ CirrusLogic5430VideoModeSetup ( Private->MaxMode = CIRRUS_LOGIC_5430_MODE_COUNT; } - FreePool (EdidOverrideDataBlock); + if (EdidOverrideDataBlock != NULL) { + FreePool (EdidOverrideDataBlock); + } + return EFI_SUCCESS; Done: