From 58c544a9bd85f4fc83ddda771beb3ff5fe80a9f1 Mon Sep 17 00:00:00 2001 From: "Ansari, Muhammad" Date: Wed, 15 Oct 2025 13:24:53 -0400 Subject: [PATCH] amd/vpelib: Fix potential overflow calculation [WHY] Multiplication result may overflow int before it is converted to long long [HOW] Updated the expression to avoid possible overflow Acked-by: Chuanyu Tseng Signed-off-by: Muhammad Ansari Part-of: --- src/amd/vpelib/src/utils/fixpt31_32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/amd/vpelib/src/utils/fixpt31_32.c b/src/amd/vpelib/src/utils/fixpt31_32.c index f04110af9c9..cb5439b7e08 100644 --- a/src/amd/vpelib/src/utils/fixpt31_32.c +++ b/src/amd/vpelib/src/utils/fixpt31_32.c @@ -259,7 +259,7 @@ struct fixed31_32 vpe_fixpt_cos(struct fixed31_32 arg) do { res = vpe_fixpt_sub( - vpe_fixpt_one, vpe_fixpt_div_int(vpe_fixpt_mul(square, res), n * (n - 1))); + vpe_fixpt_one, vpe_fixpt_div_int(vpe_fixpt_mul(square, res), (long long)n * (n - 1))); n -= 2; } while (n != 0);