[coreboot-gerrit] Patch set updated for coreboot: 35bab1e amd/pi/00730F01/Lib/amdlib.c: Integer overflow in loop construct

Edward O'Callaghan (eocallaghan@alterapraxis.com) gerrit at coreboot.org
Wed Jan 14 06:23:56 CET 2015


Edward O'Callaghan (eocallaghan at alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8208

-gerrit

commit 35bab1ef47b93645bf14aa9ad7af3d73414d50f4
Author: Edward O'Callaghan <eocallaghan at alterapraxis.com>
Date:   Wed Jan 14 02:22:01 2015 +1100

    amd/pi/00730F01/Lib/amdlib.c: Integer overflow in loop construct
    
    Forward port fix in: commit 'cb0dd58 Integer overflow in loop construct'.
    
    Change-Id: Id03900d9132477b5dd90cedd8af3a265e6f9165a
    Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
---
 src/vendorcode/amd/pi/00730F01/Lib/amdlib.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/vendorcode/amd/pi/00730F01/Lib/amdlib.c b/src/vendorcode/amd/pi/00730F01/Lib/amdlib.c
index 5e85f6b..369daea 100644
--- a/src/vendorcode/amd/pi/00730F01/Lib/amdlib.c
+++ b/src/vendorcode/amd/pi/00730F01/Lib/amdlib.c
@@ -381,11 +381,17 @@ LibAmdBitScanReverse (
   IN       UINT32 value
 )
 {
-  UINTN Index;
-  for (Index = 31; Index >= 0; Index--){
-      if (value & (1 << Index)) break;
-  }
-  return (UINT8) Index;
+  uint8_t bit = 31;
+  do {
+    if (value & (1 << 31))
+      return bit;
+
+    value <<= 1;
+    bit--;
+
+  } while (value != 0);
+
+  return 0xFF; /* Error code indicating no bit found */
 }
 
 AMDLIB_OPTIMIZE



More information about the coreboot-gerrit mailing list