ssb: Fix division by zero issue in ssb_calc_clock_rate
PATCH v2 1/1 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 <[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.
--- drivers/ssb/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ssb/main.c +1 -1
@@ -835,7 +835,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 */
Signature · 1 line
2.34.1
drivers/ssb/main.c static u32 clkfactor_f6_resolve(u32 v) · line 839
Quoted 9 lines · On Tue, 5 Sep 2023 02:23:46 +0300 Rand Deeb <[email protected]> wrote:
drivers/ssb/main.c +1
-1@@ -835,7 +835,7 @@ static u32 clkfactor_f6_resolve(u32 v)case SSB_CHIPCO_CLK_F6_7 :return 7 ; } -return 0 ; +return 1 ; }
Signature · 2 lines
Michael Büsch https://bues.ch/
Quoted 21 lines · Rand Deeb
In
ssb_calc_clock_rate(), there is a potential issue where the value of m1 could be zero due to initialization usingclkfactor_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]>--- drivers/ssb/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/ssb/main.c +0
-0
drivers/ssb/main.c static u32 clkfactor_f6_resolve(u32 v) · line 839
Quoted 6 lines
drivers/ssb/main.c +1
-1@@ -835,7 +835,7 @@ static u32 clkfactor_f6_resolve(u32 v)case SSB_CHIPCO_CLK_F6_7 :return 7 ; } -return 0 ; +return 1 ; }
Larry
Quoted 2 lines
drivers/ssb/main.c +0
-0/* Calculate the speed the backplane would run at a given set of clockcontrol values */
Quoted 11 lines · Rand Deeb
In
ssb_calc_clock_rate(), there is a potential issue where the value of m1 could be zero due to initialization usingclkfactor_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.
Quoted 3 lines
Signed-off-by Rand Deeb <[email protected]>Acked-by Larry Finger <[email protected]>Acked-by Michael Büsch <[email protected]>
Patch applied to wireless-next.git, thanks.
e0b5127fa134 ssb: Fix division by zero issue in ssb_calc_clock_rate
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches