Linux Hardware Monitor development
 help / color / mirror / Atom feed
* [PATCH v2] hwmon: (xgene-hwmon) use appropriate type for the latency value
@ 2025-02-04  9:54 Ваторопин Андрей
  2025-02-07  2:52 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Ваторопин Андрей @ 2025-02-04  9:54 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Ваторопин Андрей,
	Guenter Roeck, linux-hwmon@vger.kernel.org,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org

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 --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;
 };
 
 /*
-- 
2.43.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] hwmon: (xgene-hwmon) use appropriate type for the latency value
  2025-02-04  9:54 [PATCH v2] hwmon: (xgene-hwmon) use appropriate type for the latency value Ваторопин Андрей
@ 2025-02-07  2:52 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2025-02-07  2:52 UTC (permalink / raw)
  To: Ваторопин Андрей
  Cc: Jean Delvare, linux-hwmon@vger.kernel.org,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org

On Tue, Feb 04, 2025 at 09:54:08AM +0000, Ваторопин Андрей wrote:
> 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>

Applied.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-07  2:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-04  9:54 [PATCH v2] hwmon: (xgene-hwmon) use appropriate type for the latency value Ваторопин Андрей
2025-02-07  2:52 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox