Re: [PATCH] platform/x86: acer-wmi: fix fan mode setup in WMID_gaming_set_fan_mode()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 16.12.24 um 14:24 schrieb Dmitry Antipov:

In 'WMID_gaming_set_fan_mode()', most likely the (whether CPU or
GPU or even total) fan count is not larger than 31. But still
cast everyting to 'u64' just to be sure that there is no integer
overflow when performing left shifts. Compile tested only.

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

Reviewed-by: Armin Wolf <W_Armin@xxxxxx>

Signed-off-by: Dmitry Antipov <dmantipov@xxxxxxxxx>
---
  drivers/platform/x86/acer-wmi.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index d09baa3d3d90..9be6176c0076 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -1504,17 +1504,17 @@ static void WMID_gaming_set_fan_mode(u8 fan_mode)
  	int i;

  	if (quirks->cpu_fans > 0)
-		gpu_fan_config2 |= 1;
+		gpu_fan_config2 |= 1ULL;
  	for (i = 0; i < (quirks->cpu_fans + quirks->gpu_fans); ++i)
-		gpu_fan_config2 |= 1 << (i + 1);
+		gpu_fan_config2 |= 1ULL << (i + 1);
  	for (i = 0; i < quirks->gpu_fans; ++i)
-		gpu_fan_config2 |= 1 << (i + 3);
+		gpu_fan_config2 |= 1ULL << (i + 3);
  	if (quirks->cpu_fans > 0)
  		gpu_fan_config1 |= fan_mode;
  	for (i = 0; i < (quirks->cpu_fans + quirks->gpu_fans); ++i)
-		gpu_fan_config1 |= fan_mode << (2 * i + 2);
+		gpu_fan_config1 |= (u64)fan_mode << (2 * i + 2);
  	for (i = 0; i < quirks->gpu_fans; ++i)
-		gpu_fan_config1 |= fan_mode << (2 * i + 6);
+		gpu_fan_config1 |= (u64)fan_mode << (2 * i + 6);
  	WMID_gaming_set_u64(gpu_fan_config2 | gpu_fan_config1 << 16, ACER_CAP_TURBO_FAN);
  }






[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux