BugID:17132117: [WhiteScan] Fix overrun issue for stm32f4xx uart.c
@@ -19,7 +19,7 @@ int32_t hal_uart_init(uart_dev_t *uart)
uint8_t *rx_buf;
platform_uart_config_t config;
- if (uart->port > MICO_UART_MAX)
+ if (uart->port >= MICO_UART_MAX)
return -1;
rx_buf = (uint8_t *)malloc(UART_FIFO_SIZE);
@@ -37,7 +37,7 @@ int32_t hal_uart_init(uart_dev_t *uart)
int32_t hal_uart_finalize(uart_dev_t *uart)
{
- if (uart->port > MICO_UART_MAX)
+ if (uart->port >= MICO_UART_MAX)
return -1;
platform_uart_deinit(&platform_uart_drivers[uart->port]);
@@ -45,7 +45,7 @@ int32_t hal_uart_finalize(uart_dev_t *uart)
int32_t hal_uart_send(uart_dev_t *uart, const void *data, uint32_t size, uint32_t timeout)
{
- if (uart->port > MICO_UART_MAX)
+ if (uart->port >= MICO_UART_MAX)
return -1;
platform_uart_transmit_bytes(&platform_uart_drivers[uart->port], data, size);
@@ -54,7 +54,7 @@ int32_t hal_uart_send(uart_dev_t *uart, const void *data, uint32_t size, uint32_
int32_t hal_uart_recv_II(uart_dev_t *uart, void *data, uint32_t expect_size, uint32_t *recv_size, uint32_t timeout)
{
- if (uart->port > MICO_UART_MAX)
+ if (uart->port >= MICO_UART_MAX)
return -1;
platform_uart_receive_bytes(&platform_uart_drivers[uart->port], data, expect_size, timeout);
