提交 a7d9436a 编写于 作者: S Stephan Gerhold 提交者: Georgi Djakov

interconnect: qcom: rpm: Prevent integer overflow in rate

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
7381e27b ("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: NStephan Gerhold <stephan@gerhold.net>
Link: https://lore.kernel.org/r/20211206114542.45325-1-stephan@gerhold.netSigned-off-by: NGeorgi Djakov <djakov@kernel.org>
上级 42cdeb69
...@@ -239,6 +239,7 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst) ...@@ -239,6 +239,7 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
rate = max(sum_bw, max_peak_bw); rate = max(sum_bw, max_peak_bw);
do_div(rate, qn->buswidth); do_div(rate, qn->buswidth);
rate = min_t(u64, rate, LONG_MAX);
if (qn->rate == rate) if (qn->rate == rate)
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册