In the line 910, the value of m1 may be zero, so there is a possibility of dividing by zero, we fixed it by checking the values before dividing (found with SVACE). In the same way, after checking and reading the function, we found that lines 906, 908, 912 have the same situation, so we fixed them as well.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Rand Deeb deeb.rand@confident.ru --- drivers/ssb/main.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c index 0a26984acb2c..e0776a16d04d 100644 --- a/drivers/ssb/main.c +++ b/drivers/ssb/main.c @@ -903,13 +903,21 @@ u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m) case SSB_CHIPCO_CLK_MC_BYPASS: return clock; case SSB_CHIPCO_CLK_MC_M1: - return (clock / m1); + if (m1 != 0) + return (clock / m1); + break; case SSB_CHIPCO_CLK_MC_M1M2: - return (clock / (m1 * m2)); + if ((m1 * m2) != 0) + return (clock / (m1 * m2)); + break; case SSB_CHIPCO_CLK_MC_M1M2M3: - return (clock / (m1 * m2 * m3)); + if ((m1 * m2 * m3) != 0) + return (clock / (m1 * m2 * m3)); + break; case SSB_CHIPCO_CLK_MC_M1M3: - return (clock / (m1 * m3)); + if ((m1 * m3) != 0) + return (clock / (m1 * m3)); + break; } return 0; case SSB_PLLTYPE_2:
Dear Rand,
1. It seems you have incorrect list of recipients, please, use get_maintainers.pl to get correct one.
On 29.08.2023 14:12, Rand Deeb wrote:
In the line 910, the value of m1 may be zero, so there is a possibility of dividing by zero, we fixed it by checking the values before dividing (found with SVACE). In the same way, after checking and reading the function, we found that lines 906, 908, 912 have the same situation, so we fixed them as well.
2. It would be good to justify why zero can happen here. 3. It is not recommended to use line numbers in commit messages. 4. As for the patch, it does not have else branches and at leaset break statement should be added.
-- Alexey
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Rand Deeb deeb.rand@confident.ru
drivers/ssb/main.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c index 0a26984acb2c..e0776a16d04d 100644 --- a/drivers/ssb/main.c +++ b/drivers/ssb/main.c @@ -903,13 +903,21 @@ u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m) case SSB_CHIPCO_CLK_MC_BYPASS: return clock; case SSB_CHIPCO_CLK_MC_M1:
return (clock / m1);
if (m1 != 0)
return (clock / m1);
case SSB_CHIPCO_CLK_MC_M1M2:break;
return (clock / (m1 * m2));
if ((m1 * m2) != 0)
return (clock / (m1 * m2));
case SSB_CHIPCO_CLK_MC_M1M2M3:break;
return (clock / (m1 * m2 * m3));
if ((m1 * m2 * m3) != 0)
return (clock / (m1 * m2 * m3));
case SSB_CHIPCO_CLK_MC_M1M3:break;
return (clock / (m1 * m3));
if ((m1 * m3) != 0)
return (clock / (m1 * m3));
} return 0; case SSB_PLLTYPE_2:break;
On 29/08/2023 13:12, Rand Deeb wrote:
In the line 910, the value of m1 may be zero, so there is a possibility of dividing by zero, we fixed it by checking the values before dividing (found with SVACE). In the same way, after checking and reading the function, we found that lines 906, 908, 912 have the same situation, so we fixed them as well.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Rand Deeb deeb.rand@confident.ru
drivers/ssb/main.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c index 0a26984acb2c..e0776a16d04d 100644 --- a/drivers/ssb/main.c +++ b/drivers/ssb/main.c @@ -903,13 +903,21 @@ u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m) case SSB_CHIPCO_CLK_MC_BYPASS: return clock; case SSB_CHIPCO_CLK_MC_M1:
return (clock / m1);
if (m1 !=3D 0)
Address list does not look like patch for mainline, but anyway: Your patch is corrupted. Fix your email setup.
Best regards, Krzysztof
linux-stable-mirror@lists.linaro.org