Skip to content

Commit

Permalink
ssb: Fix division by zero issue in ssb_calc_clock_rate
Browse files Browse the repository at this point in the history
[ Upstream commit e0b5127 ]

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
<[email protected]> and Michael Büsch <[email protected]>. 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 <[email protected]>
Acked-by: Larry Finger <[email protected]>
Acked-by: Michael Büsch <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
RandDeeb authored and gregkh committed Aug 29, 2024
1 parent c51eadf commit 17e61f8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/ssb/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 17e61f8

Please sign in to comment.