lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231129065748.19871-3-quic_sibis@quicinc.com>
Date:   Wed, 29 Nov 2023 12:27:47 +0530
From:   Sibi Sankar <quic_sibis@...cinc.com>
To:     <sudeep.holla@....com>, <cristian.marussi@....com>
CC:     <linux-arm-msm@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <quic_mdtipton@...cinc.com>,
        <linux-arm-kernel@...ts.infradead.org>, <quic_asartor@...cinc.com>,
        <quic_lingutla@...cinc.com>, Sibi Sankar <quic_sibis@...cinc.com>
Subject: [PATCH 2/3] firmware: arm_scmi: Fix freq/power truncation in the perf protocol

Fix frequency and power truncation seen in the performance protocol by
casting it with the correct type.

Fixes: a9e3fbfaa0ff ("firmware: arm_scmi: add initial support for performance protocol")
Signed-off-by: Sibi Sankar <quic_sibis@...cinc.com>
---
 drivers/firmware/arm_scmi/perf.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c
index a648521e04a3..3344ce3a2026 100644
--- a/drivers/firmware/arm_scmi/perf.c
+++ b/drivers/firmware/arm_scmi/perf.c
@@ -804,9 +804,9 @@ static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph,
 
 	for (idx = 0; idx < dom->opp_count; idx++) {
 		if (!dom->level_indexing_mode)
-			freq = dom->opp[idx].perf * dom->mult_factor;
+			freq = (unsigned long)dom->opp[idx].perf * dom->mult_factor;
 		else
-			freq = dom->opp[idx].indicative_freq * 1000;
+			freq = (unsigned long)dom->opp[idx].indicative_freq * 1000;
 
 		data.level = dom->opp[idx].perf;
 		data.freq = freq;
@@ -879,7 +879,7 @@ static int scmi_dvfs_freq_get(const struct scmi_protocol_handle *ph, u32 domain,
 		return ret;
 
 	if (!dom->level_indexing_mode) {
-		*freq = level * dom->mult_factor;
+		*freq = (unsigned long)level * dom->mult_factor;
 	} else {
 		struct scmi_opp *opp;
 
@@ -887,7 +887,7 @@ static int scmi_dvfs_freq_get(const struct scmi_protocol_handle *ph, u32 domain,
 		if (!opp)
 			return -EIO;
 
-		*freq = opp->indicative_freq * 1000;
+		*freq = (unsigned long)opp->indicative_freq * 1000;
 	}
 
 	return ret;
@@ -908,9 +908,9 @@ static int scmi_dvfs_est_power_get(const struct scmi_protocol_handle *ph,
 
 	for (opp = dom->opp, idx = 0; idx < dom->opp_count; idx++, opp++) {
 		if (!dom->level_indexing_mode)
-			opp_freq = opp->perf * dom->mult_factor;
+			opp_freq = (unsigned long)opp->perf * dom->mult_factor;
 		else
-			opp_freq = opp->indicative_freq * 1000;
+			opp_freq = (unsigned long)opp->indicative_freq * 1000;
 
 		if (opp_freq < *freq)
 			continue;
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ