From: Rand Deeb Date: Mon, 4 Sep 2023 23:23:46 +0000 (+0300) Subject: ssb: Fix division by zero issue in ssb_calc_clock_rate X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=e0b5127fa134fe0284d58877b6b3133939c8b3ce;p=linux.git ssb: Fix division by zero issue in ssb_calc_clock_rate In ssb_calc_clock_rate(), there is a potential issue where the value of m1 could be zero due to initialization using clkfactor_f6_resolv(). This situation raised concerns about the possibility of a division by zero error. We fixed it by following the suggestions provided by Larry Finger and Michael Büsch . The fix involves returning a value of 1 instead of 0 in clkfactor_f6_resolv(). This modification ensures the proper functioning of the code and eliminates the risk of division by zero errors. Signed-off-by: Rand Deeb Acked-by: Larry Finger Acked-by: Michael Büsch Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20230904232346.34991-1-rand.sec96@gmail.com --- diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c index ab080cf26c9ff..b9934b9c2d708 100644 --- a/drivers/ssb/main.c +++ b/drivers/ssb/main.c @@ -837,7 +837,7 @@ static u32 clkfactor_f6_resolve(u32 v) case SSB_CHIPCO_CLK_F6_7: return 7; } - return 0; + return 1; } /* Calculate the speed the backplane would run at a given set of clockcontrol values */