can: fix unchecked return from clock_control_get_rate
Inside can_stm32_runtime_configure() result of clock_control_get_rate() is not checked which might result that function can return error and that error can not be handled Coverity-CID: 190926 Fixes: #13886 Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
This commit is contained in:
parent
5cdbd39e33
commit
d1f3bba705
1 changed files with 7 additions and 2 deletions
|
@ -210,13 +210,18 @@ int can_stm32_runtime_configure(struct device *dev, enum can_mode mode,
|
|||
u32_t bs1;
|
||||
u32_t bs2;
|
||||
u32_t sjw;
|
||||
int ret;
|
||||
|
||||
clock = device_get_binding(STM32_CLOCK_CONTROL_NAME);
|
||||
__ASSERT_NO_MSG(clock);
|
||||
hcan.Instance = can;
|
||||
|
||||
clock_control_get_rate(clock, (clock_control_subsys_t *) &cfg->pclken,
|
||||
ret = clock_control_get_rate(clock, (clock_control_subsys_t *) &cfg->pclken,
|
||||
&clock_rate);
|
||||
if (ret != 0) {
|
||||
LOG_ERR("Failed call clock_control_get_rate: return [%d]", ret);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (!bitrate) {
|
||||
bitrate = cfg->bus_speed;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue