Linux Hardware Monitor development
 help / color / mirror / Atom feed
* [PATCH] hwmon: (aquacomputer_d5next) Fix collection check for Aquaero devices
@ 2026-11-22  1:25 Guenter Roeck
  2026-11-22  1:27 ` sashiko-bot
  2026-11-22 10:57 ` Aleksa Savic
  0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2026-11-22  1:25 UTC (permalink / raw)
  To: Hardware Monitoring; +Cc: Guenter Roeck, Nandor Lieszkovszky

Commit b7743c6dbe3a ("hwmon: (aquacomputer_d5next) Check maxcollection
when probing AQUAERO devices") added a check rejecting devices with
hdev->maxcollection < 2 before inspecting hdev->collection[1].type in
aqc_probe().

Aquacomputer Aquaero 5 (0c70:f001) exposes three HID interfaces under
the same product ID: "keyboard/mouse" (3 collections, with
collection[1].type == 1), "System Control" (2 collections, with
collection[1].type == 1), and "aquaero Device", which is the sensor
interface the driver binds to and only presents a single vendor-defined
top-level collection (maxcollection == 1).

Prior to that commit, probing "aquaero Device" worked because the HID
core allocates HID_DEFAULT_NUM_COLLECTIONS (16) zero-filled entries for
hdev->collection, so hdev->collection[1].type read as 0. Rejecting
hdev->maxcollection < 2 causes aqc_probe() to return -ENODEV for
"aquaero Device" and prevents the hwmon device from registering.

Guard the hdev->collection[1].type != 0 check with
hdev->maxcollection > 1 instead of requiring at least two collections,
keeping the array access bounds-safe while allowing single-collection
Aquaero sensor interfaces to probe.

This commit was prepared with assistance from Gemini based on the bug
report and proposed fix.

Fixes: b7743c6dbe3a ("hwmon: (aquacomputer_d5next) Check maxcollection when probing AQUAERO devices")
Reported-by: Nandor Lieszkovszky <spoon3r73@googlemail.com>
Link: https://lore.kernel.org/linux-hwmon/3b6ce200-ae89-4629-a05b-bcdc503871d3@gmail.com/
Suggested-by: Nandor Lieszkovszky <spoon3r73@googlemail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/aquacomputer_d5next.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c
index f521a6142a13..884b5cf80fde 100644
--- a/drivers/hwmon/aquacomputer_d5next.c
+++ b/drivers/hwmon/aquacomputer_d5next.c
@@ -1575,9 +1575,10 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		 *
 		 * The difference between "aquaero Device" and the other two is in the collections
 		 * they present. The two other devices have the type of the second element in
-		 * their respective collections set to 1, while the real device has it set to 0.
+		 * their respective collections set to 1, while the real device either presents
+		 * a single collection or has the type of the second element set to 0.
 		 */
-		if (hdev->maxcollection < 2 || hdev->collection[1].type != 0) {
+		if (hdev->maxcollection > 1 && hdev->collection[1].type != 0) {
 			ret = -ENODEV;
 			goto fail_and_close;
 		}
-- 
2.45.2


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

end of thread, other threads:[~2026-11-22 10:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22  1:25 [PATCH] hwmon: (aquacomputer_d5next) Fix collection check for Aquaero devices Guenter Roeck
2026-11-22  1:27 ` sashiko-bot
2026-11-22 10:57 ` Aleksa Savic

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