Skip to content

Commit d1f3bba

Browse files
maxxlifenashif
authored andcommitted
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 <[email protected]>
1 parent 5cdbd39 commit d1f3bba

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/can/stm32_can.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,18 @@ int can_stm32_runtime_configure(struct device *dev, enum can_mode mode,
210210
u32_t bs1;
211211
u32_t bs2;
212212
u32_t sjw;
213+
int ret;
213214

214215
clock = device_get_binding(STM32_CLOCK_CONTROL_NAME);
215216
__ASSERT_NO_MSG(clock);
216217
hcan.Instance = can;
218+
ret = clock_control_get_rate(clock, (clock_control_subsys_t *) &cfg->pclken,
219+
&clock_rate);
220+
if (ret != 0) {
221+
LOG_ERR("Failed call clock_control_get_rate: return [%d]", ret);
222+
return -EIO;
223+
}
217224

218-
clock_control_get_rate(clock, (clock_control_subsys_t *) &cfg->pclken,
219-
&clock_rate);
220225
if (!bitrate) {
221226
bitrate = cfg->bus_speed;
222227
}

0 commit comments

Comments
 (0)