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 <jgarber1@ualberta.ca> Change-Id: I5b4e8febb68dfd244faf597dfe5cdf509af7a2ae Reviewed-on: https://review.coreboot.org/c/coreboot/+/32244 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
parent
94d61ecab0
commit
f74f6cbde5
|
@ -39,7 +39,7 @@ u32 decode_igd_memory_size(const u32 gms)
|
||||||
static const u16 ggc2uma[] = { 0, 1, 4, 8, 16, 32, 48, 64, 128, 256,
|
static const u16 ggc2uma[] = { 0, 1, 4, 8, 16, 32, 48, 64, 128, 256,
|
||||||
96, 160, 224, 352 };
|
96, 160, 224, 352 };
|
||||||
|
|
||||||
if (gms > ARRAY_SIZE(ggc2uma))
|
if (gms >= ARRAY_SIZE(ggc2uma))
|
||||||
die("Bad Graphics Mode Select (GMS) setting.\n");
|
die("Bad Graphics Mode Select (GMS) setting.\n");
|
||||||
|
|
||||||
return ggc2uma[gms] << 10;
|
return ggc2uma[gms] << 10;
|
||||||
|
|
|
@ -82,7 +82,7 @@ u32 decode_igd_memory_size(const u32 gms)
|
||||||
static const u16 ggc2uma[] = { 0, 1, 4, 8, 16, 32,
|
static const u16 ggc2uma[] = { 0, 1, 4, 8, 16, 32,
|
||||||
48, 64 };
|
48, 64 };
|
||||||
|
|
||||||
if (gms > ARRAY_SIZE(ggc2uma))
|
if (gms >= ARRAY_SIZE(ggc2uma))
|
||||||
die("Bad Graphics Mode Select (GMS) setting.\n");
|
die("Bad Graphics Mode Select (GMS) setting.\n");
|
||||||
|
|
||||||
return ggc2uma[gms] << 10;
|
return ggc2uma[gms] << 10;
|
||||||
|
|
|
@ -36,7 +36,7 @@ u32 decode_igd_memory_size(const u32 gms)
|
||||||
static const u16 ggc2uma[] = { 0, 1, 4, 8, 16,
|
static const u16 ggc2uma[] = { 0, 1, 4, 8, 16,
|
||||||
32, 48, 64, 128, 256, 96, 160, 224, 352 };
|
32, 48, 64, 128, 256, 96, 160, 224, 352 };
|
||||||
|
|
||||||
if (gms > ARRAY_SIZE(ggc2uma))
|
if (gms >= ARRAY_SIZE(ggc2uma))
|
||||||
die("Bad Graphics Mode Select (GMS) setting.\n");
|
die("Bad Graphics Mode Select (GMS) setting.\n");
|
||||||
|
|
||||||
return ggc2uma[gms] << 10;
|
return ggc2uma[gms] << 10;
|
||||||
|
@ -47,7 +47,7 @@ u32 decode_igd_gtt_size(const u32 gsm)
|
||||||
{
|
{
|
||||||
static const u8 ggc2gtt[] = { 0, 1, 0, 2, 0, 0, 0, 0, 0, 2, 3, 4};
|
static const u8 ggc2gtt[] = { 0, 1, 0, 2, 0, 0, 0, 0, 0, 2, 3, 4};
|
||||||
|
|
||||||
if (gsm > ARRAY_SIZE(ggc2gtt))
|
if (gsm >= ARRAY_SIZE(ggc2gtt))
|
||||||
die("Bad GTT Graphics Memory Size (GGMS) setting.\n");
|
die("Bad GTT Graphics Memory Size (GGMS) setting.\n");
|
||||||
|
|
||||||
return ggc2gtt[gsm] << 10;
|
return ggc2gtt[gsm] << 10;
|
||||||
|
|
Loading…
Reference in New Issue