Linux Hardware Monitor development
 help / color / mirror / Atom feed
* [PATCH v2 0/1] hwmon: (asus-ec-sensors) add missed handle for ENOMEM
@ 2026-07-12 13:00 Eugene Shalygin
  2026-07-12 13:00 ` [PATCH v2 1/1] " Eugene Shalygin
  0 siblings, 1 reply; 4+ messages in thread
From: Eugene Shalygin @ 2026-07-12 13:00 UTC (permalink / raw)
  To: eugene.shalygin
  Cc: Guenter Roeck, open list:ASUS EC HARDWARE MONITOR DRIVER,
	open list

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(-)

-- 
2.55.0


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

* [PATCH v2 1/1] hwmon: (asus-ec-sensors) add missed handle for ENOMEM
  2026-07-12 13:00 [PATCH v2 0/1] hwmon: (asus-ec-sensors) add missed handle for ENOMEM Eugene Shalygin
@ 2026-07-12 13:00 ` Eugene Shalygin
  2026-07-12 13:12   ` sashiko-bot
  0 siblings, 1 reply; 4+ messages in thread
From: Eugene Shalygin @ 2026-07-12 13:00 UTC (permalink / raw)
  To: eugene.shalygin
  Cc: Guenter Roeck, open list:ASUS EC HARDWARE MONITOR DRIVER,
	open list

Add missing return value check in the setup function.

Signed-off-by: Eugene Shalygin <eugene.shalygin@gmail.com>

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(-)

diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
index eb71e41fd4f4..6a9f369928f6 100644
--- a/drivers/hwmon/asus-ec-sensors.c
+++ b/drivers/hwmon/asus-ec-sensors.c
@@ -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++;
 	}
 
-- 
2.55.0


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

* Re: [PATCH v2 1/1] hwmon: (asus-ec-sensors) add missed handle for ENOMEM
  2026-07-12 13:00 ` [PATCH v2 1/1] " Eugene Shalygin
@ 2026-07-12 13:12   ` sashiko-bot
  2026-07-12 14:42     ` Eugene Shalygin
  0 siblings, 1 reply; 4+ messages in thread
From: sashiko-bot @ 2026-07-12 13:12 UTC (permalink / raw)
  To: Eugene Shalygin; +Cc: linux-hwmon

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 <eugene.shalygin@gmail.com>

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

Add missing return value check in the setup function.

> diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
> index 29a23484cbe7b..fc58b7eb413ee 100644
> --- a/drivers/hwmon/asus-ec-sensors.c
> +++ b/drivers/hwmon/asus-ec-sensors.c

[ ... ]

[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?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260712130345.1256030-2-eugene.shalygin@gmail.com?part=1

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

* Re: [PATCH v2 1/1] hwmon: (asus-ec-sensors) add missed handle for ENOMEM
  2026-07-12 13:12   ` sashiko-bot
@ 2026-07-12 14:42     ` Eugene Shalygin
  0 siblings, 0 replies; 4+ messages in thread
From: Eugene Shalygin @ 2026-07-12 14:42 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: linux-hwmon

On Sun, 12 Jul 2026 at 15:12, <sashiko-bot@kernel.org> 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

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

end of thread, other threads:[~2026-07-12 14:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-12 13:00 [PATCH v2 0/1] hwmon: (asus-ec-sensors) add missed handle for ENOMEM Eugene Shalygin
2026-07-12 13:00 ` [PATCH v2 1/1] " Eugene Shalygin
2026-07-12 13:12   ` sashiko-bot
2026-07-12 14:42     ` Eugene Shalygin

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