drivers: can: guard against bitrate of zero
Guard against attempts to set a bitrate of zero as this will lead to division-by-zero. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
9cb4e58a48
commit
03accdb6a8
1 changed files with 1 additions and 1 deletions
|
@ -85,7 +85,7 @@ static int can_calc_timing_int(uint32_t core_clock, struct can_timing *res,
|
|||
int sp_err;
|
||||
struct can_timing tmp_res;
|
||||
|
||||
if (sp >= 1000 ||
|
||||
if (bitrate == 0 || sp >= 1000 ||
|
||||
(!IS_ENABLED(CONFIG_CAN_FD_MODE) && bitrate > 1000000) ||
|
||||
(IS_ENABLED(CONFIG_CAN_FD_MODE) && bitrate > 8000000)) {
|
||||
return -EINVAL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue