]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
clk: qcom: clk-rpmh: prevent integer overflow in recalc_rate
authorAnastasia Belova <abelova@astralinux.ru>
Tue, 3 Dec 2024 08:42:31 +0000 (11:42 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 11:47:07 +0000 (12:47 +0100)
commit 89aa5925d201b90a48416784831916ca203658f9 upstream.

aggr_state and unit fields are u32. The result of their
multiplication may not fit in this type.

Add explicit casting to prevent overflow.

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

Fixes: 04053f4d23a4 ("clk: qcom: clk-rpmh: Add IPA clock support")
Cc: stable@vger.kernel.org # 5.4+
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Link: https://lore.kernel.org/r/20241203084231.6001-1-abelova@astralinux.ru
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/clk/qcom/clk-rpmh.c

index 6c7cce8e82f710797619cce2389ea1ca74d2d7ba..1519d9a263334f866f1b2dd37a9351e8c60244c0 100644 (file)
@@ -331,7 +331,7 @@ static unsigned long clk_rpmh_bcm_recalc_rate(struct clk_hw *hw,
 {
        struct clk_rpmh *c = to_clk_rpmh(hw);
 
-       return c->aggr_state * c->unit;
+       return (unsigned long)c->aggr_state * c->unit;
 }
 
 static const struct clk_ops clk_rpmh_bcm_ops = {