From 0e390e98677cd60cb68c99f49d11606ba213aab3 Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Mon, 7 Aug 2017 16:29:44 -0600 Subject: [PATCH] 8042: Fix error condition Since the scancode_setX arrays are defined with size [KEYBOARD_ROWS][KEYBOARD_COLS], if rows or columns are equal to either of those values, it would be accessing values outside of the array. BUG=b:64477774 TEST=Build Change-Id: I8a92d142b03281f2f4ad35eaba605b5a46df798d Signed-off-by: Martin Roth Reviewed-on: https://chromium-review.googlesource.com/606452 Commit-Ready: Martin Roth Tested-by: Martin Roth Reviewed-by: Aseda Aboagye --- common/keyboard_8042.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c index 03e0540f42..208b220659 100644 --- a/common/keyboard_8042.c +++ b/common/keyboard_8042.c @@ -313,7 +313,7 @@ static enum ec_error_list matrix_callback(int8_t row, int8_t col, ASSERT(scan_code); ASSERT(len); - if (row > KEYBOARD_ROWS || col > KEYBOARD_COLS) + if (row >= KEYBOARD_ROWS || col >= KEYBOARD_COLS) return EC_ERROR_INVAL; if (pressed)