Skip to contentSkip to conversation

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

PATCH Superseded Eugene Shalygin 2 participants 4 messages Jul 12

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Eugene Shalygin

author maintainer
#0 lore raw

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

v2: fix silly mistake when 0 would be returned from the setup function in case of error in asus_ec_hwmon_add_chan_info(), making the module load in partially initialized state.

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

 drivers/hwmon/asus-ec-sensors.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
2.55.0
author maintainer
#1 lore raw

PATCH v2 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 | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/hwmon/asus-ec-sensors.c +5 -3
index eb71e41fd4f4..6a9f369928f6 100644
@@ -1495,9 +1495,11 @@ 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]);
+		status = asus_ec_hwmon_add_chan_info(asus_ec_hwmon_chan, dev,
+						nr_count[type], type,
+						hwmon_attributes[type]);
+		if (status)
+			return status;
 		*ptr_asus_ec_ci++ = asus_ec_hwmon_chan++;
 	}
 
Signature · 1 line
2.55.0
#2 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Spurious out-of-bank EC register reads due to incorrect filtering condition in asus_ec_block_read(). --

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

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

Add missing return value check in the setup function.

drivers/hwmon/asus-ec-sensors.c

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

[ ... ]

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential issue in asus_ec_block_read() while reviewing this driver.

drivers/hwmon/asus-ec-sensors.c:asus_ec_block_read() { [ ... ]

	for (ibank = 0; ibank < ec->nr_banks; ibank++) {
		if (bank != ec->banks[ibank]) {
			bank = ec->banks[ibank];
[ ... ]
		}
		for (ireg = 0; ireg < ec->nr_registers; ireg++) {
			reg_bank = register_bank(ec->registers[ireg]);
			if (reg_bank < bank) {
				continue;
			}
			ec_read(register_index(ec->registers[ireg]),
				ec->read_buffer + ireg);
		}
	}

[ ... ]
}

Since the inner loop only skips registers from previously read banks (reg_bank < bank), does this code mistakenly read registers intended for future banks (where reg_bank > bank) while the hardware EC is still switched to the current bank?

For example, if the hardware EC is switched to bank 0, would it incorrectly read registers intended for bank 1, 2, etc., from the bank 0 hardware interface?

Could reading arbitrary Embedded Controller registers without being in the correct bank trigger clear-on-read side effects, disrupt state machines, or lock up the EC?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#3 lore raw
Quoted 4 lines · On Sun, 12 Jul 2026 at 15:12, <[email protected]> wrote:

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential issue in asus_ec_block_read() while reviewing this driver.

It went full circle; the fix for that is submitted as "hwmon:
(asus-ec-sensors) fix looping over banks while reading from EC".

Eugene