driver: serial: Error handling issues in uart_stm32_set_baudrate

This patch tests the return code when calling clock_control_get_rate
and completes the issue #20503 seen on watchdog
[Coverity CID :205655]

Fixes #20503

Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
Francois Ramu 2019-11-12 16:13:03 +01:00 committed by Maureen Helm
commit d3ffa8d089

View file

@ -24,6 +24,9 @@
#include <clock_control/stm32_clock_control.h>
#include "uart_stm32.h"
#include <logging/log.h>
LOG_MODULE_REGISTER(uart_stm32);
/* convenience defines */
#define DEV_CFG(dev) \
((const struct uart_stm32_config * const)(dev)->config->config_info)
@ -43,10 +46,12 @@ static inline void uart_stm32_set_baudrate(struct device *dev, u32_t baud_rate)
u32_t clock_rate;
/* Get clock rate */
clock_control_get_rate(data->clock,
if (clock_control_get_rate(data->clock,
(clock_control_subsys_t *)&config->pclken,
&clock_rate);
&clock_rate) < 0) {
LOG_ERR("Failed call clock_control_get_rate");
return;
}
#ifdef CONFIG_LPUART_1