Skip to contentSkip to conversation

ssb: Fix division by zero issue in ssb_calc_clock_rate

PATCH In review Rand Deeb 4 participants 4 messages Sep 4, 2023 – Sep 7, 2023 Sonics silicon backplane driver (ssb)

lore
Share & tools
lore

Rand Deeb

author
#0 lore raw

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
index 0a26984acb2c..9e54bc7eec66 100644
@@ -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
maintainer Acked-by on v2 1/1
#1 lore raw

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/
Acked-by on v2 1/1
#2 lore raw
In reply to Rand Deeb
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 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 +0 -0
index 0a26984acb2c..9e54bc7eec66 100644

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 */
#3 lore raw
In reply to Rand Deeb
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 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.

Quoted 3 lines

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