Resolve a bug where the initial ReadEdidData 'for' loop would loop
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 24 Nov 2008 00:30:53 +0000 (00:30 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 24 Nov 2008 00:30:53 +0000 (00:30 +0000)
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

OptionRomPkg/CirrusLogic5430Dxe/Edid.c

index 76a74ccf5ec996794c14109c4c4a5486da245494..73999e3f1531166980daa3da40850e4594e80695 100644 (file)
@@ -112,7 +112,7 @@ ReadEdidData (
   UINTN                              *EdidSize\r
   )\r
 {\r
-  UINT8             Index;\r
+  UINTN             Index;\r
   UINT8             EdidData[EDID_BLOCK_SIZE * 2];\r
   UINT8             *ValidEdid;\r
   UINT64            Signature;\r
@@ -397,7 +397,7 @@ CirrusLogic5430VideoModeSetup (
     // If EDID Override data doesn't exist or EFI_EDID_OVERRIDE_DONT_OVERRIDE returned,\r
     // read EDID information through I2C Bus\r
     //\r
-    if (ReadEdidData (Private, &EdidDiscoveredDataBlock, &EdidDiscoveredDataSize) == EFI_SUCCESS) {;\r
+    if (ReadEdidData (Private, &EdidDiscoveredDataBlock, &EdidDiscoveredDataSize) == EFI_SUCCESS) {\r
       Private->EdidDiscovered.SizeOfEdid = (UINT32) EdidDiscoveredDataSize;\r
        Private->EdidDiscovered.Edid = (UINT8 *) AllocateCopyPool (\r
                                                           EdidDiscoveredDataSize,\r
@@ -509,7 +509,10 @@ CirrusLogic5430VideoModeSetup (
     Private->MaxMode = CIRRUS_LOGIC_5430_MODE_COUNT;\r
   }\r
 \r
-  FreePool (EdidOverrideDataBlock);\r
+  if (EdidOverrideDataBlock != NULL) {\r
+    FreePool (EdidOverrideDataBlock);\r
+  }\r
+\r
   return EFI_SUCCESS;\r
 \r
 Done:\r