Skip to contentSkip to conversation

hwmon: (aquacomputer_d5next) Fix collection check for Aquaero devices

PATCH In review Guenter Roeck 3 participants 3 messages Nov 22

Subsystems (2)
lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 1/1 hwmon: (aquacomputer_d5next) Fix collection check for Aquaero devices

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")
---
 drivers/hwmon/aquacomputer_d5next.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/hwmon/aquacomputer_d5next.c +3 -2
index f521a6142a13..884b5cf80fde 100644
@@ -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;
 		}
Signature · 1 line
2.45.2
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 15 lines

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

Quoted 6 lines
[ ... ]
Fixes b7743c6dbe3a ("hwmon: (aquacomputer_d5next) Check maxcollection when probing AQUAERO devices")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1