diff options
author | Stephan Gerhold <stephan@gerhold.net> | 2021-12-06 12:45:42 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-01-27 11:05:00 +0100 |
commit | d90d496a999ed1e7909e8e24f452c0b7b444a636 (patch) | |
tree | 2ffeb921739caf24bfe6c70a402bb690a274845e /drivers/interconnect | |
parent | efd507bed1b4ba0f32ece009c34e462392e6de7c (diff) | |
download | linux-stable-d90d496a999ed1e7909e8e24f452c0b7b444a636.tar.gz linux-stable-d90d496a999ed1e7909e8e24f452c0b7b444a636.tar.bz2 linux-stable-d90d496a999ed1e7909e8e24f452c0b7b444a636.zip |
interconnect: qcom: rpm: Prevent integer overflow in rate
[ Upstream commit a7d9436a6c85fcb8843c910fd323dcd7f839bf63 ]
Using icc-rpm on ARM32 currently results in clk_set_rate() errors during
boot, e.g. "bus clk_set_rate error: -22". This is very similar to commit
7381e27b1e56 ("interconnect: qcom: msm8974: Prevent integer overflow in rate")
where the u64 is converted to a signed long during clock rate rounding,
resulting in an overflow on 32-bit platforms.
Let's fix it similarly by making sure that the rate does not exceed
LONG_MAX. Such high clock rates will surely result in the maximum
frequency of the bus anyway.
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Link: https://lore.kernel.org/r/20211206114542.45325-1-stephan@gerhold.net
Signed-off-by: Georgi Djakov <djakov@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/interconnect')
-rw-r--r-- | drivers/interconnect/qcom/icc-rpm.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c index 54de49ca7808..ddf1805ded0c 100644 --- a/drivers/interconnect/qcom/icc-rpm.c +++ b/drivers/interconnect/qcom/icc-rpm.c @@ -68,6 +68,7 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst) rate = max(sum_bw, max_peak_bw); do_div(rate, qn->buswidth); + rate = min_t(u64, rate, LONG_MAX); if (qn->rate == rate) return 0; |