Skip to contentSkip to conversation

hwmon: (asus-ec-sensors) add missed handle for ENOMEM

PATCH Superseded Eugene Shalygin 2 participants 2 messages Jul 12

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Eugene Shalygin

author maintainer
#0 lore raw

PATCH 1/1 hwmon: (asus-ec-sensors) add missed handle for ENOMEM

Add missing return value check in the setup function.

Fixes d0ddfd241e57 ("hwmon: (asus-ec-sensors) add driver for ASUS EC")
---
 drivers/hwmon/asus-ec-sensors.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/hwmon/asus-ec-sensors.c +4 -3
index eb71e41fd4f4..2be8824e3c62 100644
@@ -1495,9 +1495,10 @@ static int asus_ec_probe(struct platform_device *pdev)
 		if (!nr_count[type])
 			continue;
 
-		asus_ec_hwmon_add_chan_info(asus_ec_hwmon_chan, dev,
-					     nr_count[type], type,
-					     hwmon_attributes[type]);
+		if (asus_ec_hwmon_add_chan_info(asus_ec_hwmon_chan, dev,
+						nr_count[type], type,
+						hwmon_attributes[type]))
+			return status;
 		*ptr_asus_ec_ci++ = asus_ec_hwmon_chan++;
 	}
 
Signature · 1 line
2.55.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The newly added error handling incorrectly returns `status` (which evaluates to 0) instead of the…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The newly added error handling incorrectly returns status (which evaluates to 0) instead of the actual error code when asus_ec_hwmon_add_chan_info() fails. --

--- Patch [1]: [PATCH] hwmon: (asus-ec-sensors) add missed handle for ENOMEM --- commit 2fb0c06e28b3b0aad223266de4f30ef04ff0537b
Author: Eugene Shalygin <[email protected]>

hwmon: (asus-ec-sensors) add missed handle for ENOMEM

This commit adds a missing return value check in the setup function asus_ec_probe() to handle potential memory allocation failures.

Quoted 5 lines
drivers/hwmon/asus-ec-sensors.c +0 -0
index 29a23484cbe7b..dd8c1a3f182e3 100644

drivers/hwmon/asus-ec-sensors.c static int asus_ec_probe(struct platform_device *pdev) · line 1501

Quoted 10 lines
drivers/hwmon/asus-ec-sensors.c +4 -3
@@ -1495,9 +1495,10 @@ static int asus_ec_probe(struct platform_device *pdev)
 		if (!nr_count[type])
 			continue;
 
-		asus_ec_hwmon_add_chan_info(asus_ec_hwmon_chan, dev,
-					     nr_count[type], type,
-					     hwmon_attributes[type]);
+		if (asus_ec_hwmon_add_chan_info(asus_ec_hwmon_chan, dev,
+						nr_count[type], type,
+						hwmon_attributes[type]))
+			return status;

[Severity: High]
Does this correctly return the error code? At this point in asus_ec_probe(), status appears to be 0 from the earlier successful call to setup_lock_data().

Should this capture and return the actual error code from asus_ec_hwmon_add_chan_info() instead, to avoid returning success (0) while aborting the probe?

Quoted 2 lines
drivers/hwmon/asus-ec-sensors.c +0 -0
 		*ptr_asus_ec_ci++ = asus_ec_hwmon_chan++;
 	}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1