[PATCH] clk: sunxi: add explicit casting to prevent overflow

From: Anastasia Belova
Date: Mon Jan 20 2025 - 03:57:43 EST


If n = 255, the result of multiplication of n and 24000000
may not fit int type. Add explicit casting to prevent overflow.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 6424e0aeebc4 ("clk: sunxi: rewrite sun9i_a80_get_pll4_factors()")
Signed-off-by: Anastasia Belova <abelova@xxxxxxxxxxxxx>
---
drivers/clk/sunxi/clk-sun9i-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/sunxi/clk-sun9i-core.c b/drivers/clk/sunxi/clk-sun9i-core.c
index d93c7a53c6c0..70fbd7390d96 100644
--- a/drivers/clk/sunxi/clk-sun9i-core.c
+++ b/drivers/clk/sunxi/clk-sun9i-core.c
@@ -50,7 +50,7 @@ static void sun9i_a80_get_pll4_factors(struct factors_request *req)
else if (n < 12)
n = 12;

- req->rate = ((24000000 * n) >> p) / (m + 1);
+ req->rate = ((24000000ULL * n) >> p) / (m + 1);
req->n = n;
req->m = m;
req->p = p;
--
2.43.0