summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacob Garber <jgarber1@ualberta.ca>2019-07-26 15:20:47 -0600
committerPatrick Georgi <pgeorgi@google.com>2019-07-30 09:55:55 +0000
commit9f378d3b0395b2e7b5a8972cf69f1c6fdcabfe09 (patch)
tree779f31f487ccdee8e4a51d13393f19161ae9a8bc /src
parentc1e9ba8c3d03cb3656237c0e126b35bea548d5cc (diff)
vc/cavium/bdk/libdram: Add array bounds check
Ensure that best_en_idx is within bounds before accessing the _en array. Change-Id: Ifa6259e28875a8cf8199896bda7982370ccaa277 Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Found-by: Coverity CID 1393971 Reviewed-on: https://review.coreboot.org/c/coreboot/+/34593 Reviewed-by: Patrick Rudolph <siro@das-labor.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r--src/vendorcode/cavium/bdk/libdram/lib_octeon_shared.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/vendorcode/cavium/bdk/libdram/lib_octeon_shared.c b/src/vendorcode/cavium/bdk/libdram/lib_octeon_shared.c
index 7ee91c27c3..cb090f7da5 100644
--- a/src/vendorcode/cavium/bdk/libdram/lib_octeon_shared.c
+++ b/src/vendorcode/cavium/bdk/libdram/lib_octeon_shared.c
@@ -1141,6 +1141,11 @@ int initialize_ddr_clock(bdk_node_t node,
override_pll_settings = 1;
}
+ if (best_en_idx >= ARRAY_SIZE(_en)) {
+ error_print("ERROR: best_en_idx %u exceeds _en array size\n", best_en_idx);
+ return -1;
+ }
+
if (override_pll_settings) {
best_pll_MHz = ddr_ref_hertz * (best_clkf+1) / (best_clkr+1) / 1000000;
best_calculated_ddr_hertz = ddr_ref_hertz * (best_clkf + 1) / ((best_clkr + 1) * (_en[best_en_idx]));