ssb: Fix division by zero issue in ssb_calc_clock_rate
authorRand Deeb <rand.sec96@gmail.com>
Mon, 4 Sep 2023 23:23:46 +0000 (02:23 +0300)
committerKalle Valo <kvalo@kernel.org>
Thu, 7 Sep 2023 06:00:05 +0000 (09:00 +0300)
commite0b5127fa134fe0284d58877b6b3133939c8b3ce
tree55520375307a99c0a821b7bee159f3bbe131b71d
parentb227c990de9a3af37d1c9e6fd9b193145b4ca779
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
<Larry.Finger@lwfinger.net> and Michael Büsch <m@bues.ch>. 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 <rand.sec96@gmail.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Acked-by: Michael Büsch <m@bues.ch>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230904232346.34991-1-rand.sec96@gmail.com
drivers/ssb/main.c