X86 platform drivers
 help / color / mirror / Atom feed
* [PATCH 0/2] platform/x86: alienware-wmi-wmax: Fix unitialized variables in awcc_hwmon_fans_init()
@ 2025-04-25 15:45 Kurt Borja via B4 Relay
  2025-04-25 15:45 ` [PATCH 1/2] platform/x86: alienware-wmi-wmax: Fix uninitialized bitmap " Kurt Borja via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kurt Borja via B4 Relay @ 2025-04-25 15:45 UTC (permalink / raw)
  To: Ilpo Järvinen, Hans de Goede, Armin Wolf
  Cc: platform-driver-x86, Dell.Client.Kernel, linux-kernel, Kurt Borja,
	kernel test robot, Dan Carpenter

Hi Ilpo,

These are based on the for-next branch. Thanks!

Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
Kurt Borja (2):
      platform/x86: alienware-wmi-wmax: Fix uninitialized bitmap in awcc_hwmon_fans_init()
      platform/x86: alienware-wmi-wmax: Fix awcc_hwmon_fans_init() label logic

 drivers/platform/x86/dell/alienware-wmi-wmax.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
---
base-commit: 981527828c301644bc4014faa9c523e8a5e32a32
change-id: 20250425-temp-id-fix-1a2ecd70e391

Best regards,
-- 
 ~ Kurt



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

* [PATCH 1/2] platform/x86: alienware-wmi-wmax: Fix uninitialized bitmap in awcc_hwmon_fans_init()
  2025-04-25 15:45 [PATCH 0/2] platform/x86: alienware-wmi-wmax: Fix unitialized variables in awcc_hwmon_fans_init() Kurt Borja via B4 Relay
@ 2025-04-25 15:45 ` Kurt Borja via B4 Relay
  2025-04-25 15:45 ` [PATCH 2/2] platform/x86: alienware-wmi-wmax: Fix awcc_hwmon_fans_init() label logic Kurt Borja via B4 Relay
  2025-04-29 14:12 ` [PATCH 0/2] platform/x86: alienware-wmi-wmax: Fix unitialized variables in awcc_hwmon_fans_init() Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Kurt Borja via B4 Relay @ 2025-04-25 15:45 UTC (permalink / raw)
  To: Ilpo Järvinen, Hans de Goede, Armin Wolf
  Cc: platform-driver-x86, Dell.Client.Kernel, linux-kernel, Kurt Borja

From: Kurt Borja <kuurtb@gmail.com>

Initialize fan_temps bitmap to zero before using it for the first time
in each iteration.

Fixes: d69990783495 ("platform/x86: alienware-wmi-wmax: Add HWMON support")
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
 drivers/platform/x86/dell/alienware-wmi-wmax.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platform/x86/dell/alienware-wmi-wmax.c
index faeddfe3b79e0aa51e7c8c6b23aa4ac5c7218706..27e5b0b23c27356cd5d72dbc5d3b5b4bdb03e8af 100644
--- a/drivers/platform/x86/dell/alienware-wmi-wmax.c
+++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c
@@ -1027,6 +1027,8 @@ static int awcc_hwmon_fans_init(struct wmi_device *wdev)
 		if (ret)
 			return ret;
 
+		bitmap_zero(fan_temps, AWCC_ID_BITMAP_SIZE);
+
 		for (j = 0; j < temp_count; j++) {
 			ret = awcc_get_fan_sensors(wdev, AWCC_OP_GET_FAN_TEMP_ID,
 						   id, j, &temp_id);
@@ -1048,8 +1050,6 @@ static int awcc_hwmon_fans_init(struct wmi_device *wdev)
 		bitmap_gather(gather, fan_temps, priv->temp_sensors, AWCC_ID_BITMAP_SIZE);
 		bitmap_copy(&fan_data->auto_channels_temp, gather, BITS_PER_LONG);
 		priv->fan_data[i] = fan_data;
-
-		bitmap_zero(fan_temps, AWCC_ID_BITMAP_SIZE);
 	}
 
 	return 0;

-- 
2.49.0



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

* [PATCH 2/2] platform/x86: alienware-wmi-wmax: Fix awcc_hwmon_fans_init() label logic
  2025-04-25 15:45 [PATCH 0/2] platform/x86: alienware-wmi-wmax: Fix unitialized variables in awcc_hwmon_fans_init() Kurt Borja via B4 Relay
  2025-04-25 15:45 ` [PATCH 1/2] platform/x86: alienware-wmi-wmax: Fix uninitialized bitmap " Kurt Borja via B4 Relay
@ 2025-04-25 15:45 ` Kurt Borja via B4 Relay
  2025-04-29 14:12 ` [PATCH 0/2] platform/x86: alienware-wmi-wmax: Fix unitialized variables in awcc_hwmon_fans_init() Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Kurt Borja via B4 Relay @ 2025-04-25 15:45 UTC (permalink / raw)
  To: Ilpo Järvinen, Hans de Goede, Armin Wolf
  Cc: platform-driver-x86, Dell.Client.Kernel, linux-kernel, Kurt Borja,
	kernel test robot, Dan Carpenter

From: Kurt Borja <kuurtb@gmail.com>

To avoid passing an uninitialized `temp_id` to awcc_get_fan_label(),
pass the `fan_temps` bitmap instead, to work only on set bits.

Additionally, awcc_get_fan_label() leaves `dev` unused, so remove it
from it's signature and it does not fail, so remove error handling.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202504250521.HEkFK1Jy-lkp@intel.com/
Fixes: d69990783495 ("platform/x86: alienware-wmi-wmax: Add HWMON support")
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
 drivers/platform/x86/dell/alienware-wmi-wmax.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platform/x86/dell/alienware-wmi-wmax.c
index 27e5b0b23c27356cd5d72dbc5d3b5b4bdb03e8af..f3ad47c9edfac47fae181046acae2190e388306c 100644
--- a/drivers/platform/x86/dell/alienware-wmi-wmax.c
+++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c
@@ -958,15 +958,19 @@ static int awcc_hwmon_temps_init(struct wmi_device *wdev)
 	return 0;
 }
 
-static char *awcc_get_fan_label(struct device *dev, u32 temp_count, u8 temp_id)
+static char *awcc_get_fan_label(unsigned long *fan_temps)
 {
+	unsigned int temp_count = bitmap_weight(fan_temps, AWCC_ID_BITMAP_SIZE);
 	char *label;
+	u8 temp_id;
 
 	switch (temp_count) {
 	case 0:
 		label = "Independent Fan";
 		break;
 	case 1:
+		temp_id = find_first_bit(fan_temps, AWCC_ID_BITMAP_SIZE);
+
 		switch (temp_id) {
 		case AWCC_TEMP_SENSOR_CPU:
 			label = "Processor Fan";
@@ -996,7 +1000,6 @@ static int awcc_hwmon_fans_init(struct wmi_device *wdev)
 	u32 min_rpm, max_rpm, temp_count, temp_id;
 	struct awcc_fan_data *fan_data;
 	unsigned int i, j;
-	char *label;
 	int ret;
 	u8 id;
 
@@ -1039,14 +1042,10 @@ static int awcc_hwmon_fans_init(struct wmi_device *wdev)
 			__set_bit(temp_id, fan_temps);
 		}
 
-		label = awcc_get_fan_label(&wdev->dev, temp_count, temp_id);
-		if (!label)
-			return -ENOMEM;
-
 		fan_data->id = id;
 		fan_data->min_rpm = min_rpm;
 		fan_data->max_rpm = max_rpm;
-		fan_data->label = label;
+		fan_data->label = awcc_get_fan_label(fan_temps);
 		bitmap_gather(gather, fan_temps, priv->temp_sensors, AWCC_ID_BITMAP_SIZE);
 		bitmap_copy(&fan_data->auto_channels_temp, gather, BITS_PER_LONG);
 		priv->fan_data[i] = fan_data;

-- 
2.49.0



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

* Re: [PATCH 0/2] platform/x86: alienware-wmi-wmax: Fix unitialized variables in awcc_hwmon_fans_init()
  2025-04-25 15:45 [PATCH 0/2] platform/x86: alienware-wmi-wmax: Fix unitialized variables in awcc_hwmon_fans_init() Kurt Borja via B4 Relay
  2025-04-25 15:45 ` [PATCH 1/2] platform/x86: alienware-wmi-wmax: Fix uninitialized bitmap " Kurt Borja via B4 Relay
  2025-04-25 15:45 ` [PATCH 2/2] platform/x86: alienware-wmi-wmax: Fix awcc_hwmon_fans_init() label logic Kurt Borja via B4 Relay
@ 2025-04-29 14:12 ` Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2025-04-29 14:12 UTC (permalink / raw)
  To: Hans de Goede, Armin Wolf, Kurt Borja
  Cc: platform-driver-x86, Dell.Client.Kernel, linux-kernel,
	kernel test robot, Dan Carpenter

On Fri, 25 Apr 2025 12:45:05 -0300, Kurt Borja wrote:

> These are based on the for-next branch. Thanks!
> 
> 


Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/2] platform/x86: alienware-wmi-wmax: Fix uninitialized bitmap in awcc_hwmon_fans_init()
      commit: 8bb4c64d07c294899189a1f9a61cbef706ae91dd
[2/2] platform/x86: alienware-wmi-wmax: Fix awcc_hwmon_fans_init() label logic
      commit: af6e2f91cc534e8ec1afdb458cf6efd4064f394d

--
 i.


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

end of thread, other threads:[~2025-04-29 14:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-25 15:45 [PATCH 0/2] platform/x86: alienware-wmi-wmax: Fix unitialized variables in awcc_hwmon_fans_init() Kurt Borja via B4 Relay
2025-04-25 15:45 ` [PATCH 1/2] platform/x86: alienware-wmi-wmax: Fix uninitialized bitmap " Kurt Borja via B4 Relay
2025-04-25 15:45 ` [PATCH 2/2] platform/x86: alienware-wmi-wmax: Fix awcc_hwmon_fans_init() label logic Kurt Borja via B4 Relay
2025-04-29 14:12 ` [PATCH 0/2] platform/x86: alienware-wmi-wmax: Fix unitialized variables in awcc_hwmon_fans_init() Ilpo Järvinen

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