From f74f6cbde5b51bb85fa3b20b80f482ef41eb7e9b Mon Sep 17 00:00:00 2001 From: Jacob Garber Date: Mon, 8 Apr 2019 17:54:35 -0600 Subject: nb/intel/{gm45,i945,x4x}: Correct array bounds checks There will be an out of bounds read if the index is equal to the array size. Fix the checks to exclude this case. Found-by: Coverity Scan, CID 1347350, 1347351 Signed-off-by: Jacob Garber Change-Id: I5b4e8febb68dfd244faf597dfe5cdf509af7a2ae Reviewed-on: https://review.coreboot.org/c/coreboot/+/32244 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- src/northbridge/intel/i945/ram_calc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/northbridge/intel/i945') diff --git a/src/northbridge/intel/i945/ram_calc.c b/src/northbridge/intel/i945/ram_calc.c index 124a6a8317..752c8f901c 100644 --- a/src/northbridge/intel/i945/ram_calc.c +++ b/src/northbridge/intel/i945/ram_calc.c @@ -82,7 +82,7 @@ u32 decode_igd_memory_size(const u32 gms) static const u16 ggc2uma[] = { 0, 1, 4, 8, 16, 32, 48, 64 }; - if (gms > ARRAY_SIZE(ggc2uma)) + if (gms >= ARRAY_SIZE(ggc2uma)) die("Bad Graphics Mode Select (GMS) setting.\n"); return ggc2uma[gms] << 10; -- cgit v1.2.3