From efd23d92efb982f74b8473201bc93b1c0ad64bc8 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Wed, 10 Jun 2020 19:39:51 +0200 Subject: soc/amd/picasso/uart: fix possible out of bounds access Found-by: Coverity CID 1429769, 1429777 Change-Id: Ide188379a34c769c929bf7832fd94a7004c09a64 Signed-off-by: Felix Held Reviewed-on: https://review.coreboot.org/c/coreboot/+/42253 Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) --- src/soc/amd/picasso/uart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/soc/amd/picasso/uart.c b/src/soc/amd/picasso/uart.c index b1331ec603..84d6982968 100644 --- a/src/soc/amd/picasso/uart.c +++ b/src/soc/amd/picasso/uart.c @@ -32,7 +32,7 @@ static const struct _uart_info { uintptr_t uart_platform_base(int idx) { - if (idx < 0 || idx > ARRAY_SIZE(uart_info)) + if (idx < 0 || idx >= ARRAY_SIZE(uart_info)) return 0; return uart_info[idx].base; @@ -43,7 +43,7 @@ void set_uart_config(int idx) uint32_t uart_ctrl; uint16_t uart_leg; - if (idx < 0 || idx > ARRAY_SIZE(uart_info)) + if (idx < 0 || idx >= ARRAY_SIZE(uart_info)) return; program_gpios(uart_info[idx].mux, 2); -- cgit v1.2.3