From 3312ed7e7a0b3269d6559207cdf9ed932ffecd31 Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Thu, 22 May 2014 03:36:22 +1000 Subject: amd/agesa/f1?/Lib/amdlib.c: Integer overflow in loop construct The semantics of this loop relies on an integer overflow in Index >=0 that implies a return value of (UINT8)-1 which around wraps to 0xFF, or VOLT_UNSUPPORTED. Change-Id: I44d68973d0a80093350b2a8a4d3b46bfbb57917a Signed-off-by: Edward O'Callaghan Reviewed-on: http://review.coreboot.org/5801 Tested-by: build bot (Jenkins) Reviewed-by: Marc Jones --- src/vendorcode/amd/agesa/f15tn/Lib/amdlib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/vendorcode/amd/agesa/f15tn') diff --git a/src/vendorcode/amd/agesa/f15tn/Lib/amdlib.c b/src/vendorcode/amd/agesa/f15tn/Lib/amdlib.c index 55adc8a..9646e6d 100644 --- a/src/vendorcode/amd/agesa/f15tn/Lib/amdlib.c +++ b/src/vendorcode/amd/agesa/f15tn/Lib/amdlib.c @@ -359,11 +359,11 @@ LibAmdBitScanReverse ( IN UINT32 value ) { - UINTN Index; + UINT8 Index; for (Index = 31; Index >= 0; Index--){ - if (value & (1 << Index)) break; + if (value & (1 << Index)) return Index; } - return (UINT8) Index; + return 0xFF; } VOID LibAmdMsrRead ( -- cgit v1.1