diff mbox series

[v2] hwmon: (xgene-hwmon) use appropriate type for the latency value

Message ID 20250204095400.95013-1-a.vatoropin@crpt.ru (mailing list archive)
State New
Headers show
Series [v2] hwmon: (xgene-hwmon) use appropriate type for the latency value | expand

Commit Message

Ваторопин Андрей Feb. 4, 2025, 9:54 a.m. UTC
From: Andrey Vatoropin <a.vatoropin@crpt.ru>

The expression PCC_NUM_RETRIES * pcc_chan->latency is currently being
evaluated using 32-bit arithmetic.

Since a value of type 'u64' is used to store the eventual result,
and this result is later sent to the function usecs_to_jiffies with 
input parameter unsigned int, the current data type is too wide to 
store the value of ctx->usecs_lat.

Change the data type of "usecs_lat" to a more suitable (narrower) type.

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

Signed-off-by: Andrey Vatoropin <a.vatoropin@crpt.ru>
---
v1->v2: rework the patch by utilizing more appropriate data types for
the variables in question as Guenter Roeck noticed.
 drivers/hwmon/xgene-hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c
index 1e3bd129a922..72ba569dde1c 100644
--- a/drivers/hwmon/xgene-hwmon.c
+++ b/drivers/hwmon/xgene-hwmon.c
@@ -105,7 +105,7 @@  struct xgene_hwmon_dev {
 
 	phys_addr_t		comm_base_addr;
 	void			*pcc_comm_addr;
-	u64			usecs_lat;
+	unsigned int		usecs_lat;
 };
 
 /*