Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>,
	Nandor Lieszkovszky <spoon3r73@googlemail.com>
Subject: [PATCH] hwmon: (aquacomputer_d5next) Fix collection check for Aquaero devices
Date: Sat, 21 Nov 2026 17:25:28 -0800	[thread overview]
Message-ID: <20261122012528.881538-1-linux@roeck-us.net> (raw)

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


             reply	other threads:[~2026-11-22  1:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  1:25 Guenter Roeck [this message]
2026-11-22  1:27 ` [PATCH] hwmon: (aquacomputer_d5next) Fix collection check for Aquaero devices sashiko-bot
2026-11-22 10:57 ` Aleksa Savic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261122012528.881538-1-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=spoon3r73@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox