summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2021-10-02 00:02:48 +0000
committerCommit Bot <commit-bot@chromium.org>2021-10-13 19:20:35 +0000
commitb3ef50743dacfe10bcca63b2017d92af438f87c8 (patch)
tree276f4a6ca9d72ca50e75b673e330398a79750694 /chip
parente2d5e48487158ccfaa3e0e796e7f1da0761b02b0 (diff)
downloadchrome-ec-b3ef50743dacfe10bcca63b2017d92af438f87c8.tar.gz
chip/stm32: Avoid out of bounds array access on TCPCI_MSG_TX_BIST_MODE_2
clang warns: chip/stm32/ucpd-stm32gx.c:797:5: error: array index 582424 is past the end of the array (which contains 7 elements) [-Werror,-Warray-bounds] ucpd_txorderset[TX_ORDERSET_SOP]; ^ ~~~~~~~~~~~~~~~ chip/stm32/ucpd-stm32gx.c:127:1: note: array 'ucpd_txorderset' declared here static int ucpd_txorderset[] = { The if clause handles SOP -> Cable Reset and the only type that does not handle is TCPCI_MSG_TX_BIST_MODE_2. That case is a "don't care" for sync packets as it's just a continuous 1/0 bit pattern. BRANCH=none BUG=b:172020503 TEST=make CC=arm-none-eabi-clang BOARD=baklava Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ia2b73bcbf7eabe2de480633d4e65b8df55137e2e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3198206 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/stm32/ucpd-stm32gx.c3
1 files changed, 0 insertions, 3 deletions
diff --git a/chip/stm32/ucpd-stm32gx.c b/chip/stm32/ucpd-stm32gx.c
index ef6ec92a89..ce5b82fff8 100644
--- a/chip/stm32/ucpd-stm32gx.c
+++ b/chip/stm32/ucpd-stm32gx.c
@@ -792,9 +792,6 @@ static int stm32gx_ucpd_start_transmit(int port, enum ucpd_tx_msg msg_type)
/* Index into ordset enum for start of packet */
if (type <= TCPCI_MSG_CABLE_RESET)
STM32_UCPD_TX_ORDSETR(port) = ucpd_txorderset[type];
- else
- STM32_UCPD_TX_ORDSETR(port) =
- ucpd_txorderset[TX_ORDERSET_SOP];
/* Reset msg byte index */
ucpd_tx_active_buffer-> msg_index = 0;