From 03accdb6a86c7f3f6e6700a3ab5f7b278bc57c15 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Fri, 18 Mar 2022 10:35:27 +0100 Subject: [PATCH] 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 --- drivers/can/can_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/can/can_common.c b/drivers/can/can_common.c index f5f3cc7b17f..fe5e3779220 100644 --- a/drivers/can/can_common.c +++ b/drivers/can/can_common.c @@ -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;