Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vas Zayarskiy" <contact@vasily.cc>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] hwmon: (aquacomputer_d5next) Add AMPINEL support
Date: Mon, 14 Sep 2026 20:08:30 +0000	[thread overview]
Message-ID: <20260914200831.5642E1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260914195759.171524-1-contact@vasily.cc>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] The driver unconditionally casts the device parent to a `usb_interface` without verifying that the device is actually bound to a USB transport, which can lead to an invalid cast and kernel crash.
--

commit ab9f1cda999fbdfa626d75acef47522f86ec7022
Author: Vas Zayarskiy <contact@vasily.cc>

hwmon: (aquacomputer_d5next) Add AMPINEL support

This commit adds read-only hardware monitoring support for the Aquacomputer
AMPINEL power monitor. It decodes the USB HID input reports to expose total
power, voltage, current, and temperature telemetry through standard hwmon
interfaces.

> diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c
> index 1ca70e7262988..b33d0ccc02183 100644
> --- a/drivers/hwmon/aquacomputer_d5next.c
> +++ b/drivers/hwmon/aquacomputer_d5next.c
[ ... ]
> @@ -1533,6 +1626,27 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  	if (ret)
>  		return ret;
>  
> +	if (hdev->product == USB_PRODUCT_ID_AMPINEL) {
> +		intf = to_usb_interface(hdev->dev.parent);

[Severity: Critical]
Is it safe to cast the parent device to a usb_interface here without first
verifying that this is a USB device?

If a non-USB HID device matching this vendor (0x0c70) and product (0xf015) ID
is registered (for example, spoofed over Bluetooth or by a local attacker
using /dev/uhid), to_usb_interface() will perform an invalid cast. 

The subsequent dereference of intf->cur_altsetting could then cause an OOPS
or memory corruption due to type confusion.

Would it be better to add a hid_is_usb(hdev) check before attempting this
cast?

> +		/*
> +		 * hid-generic yields every interface matching our product ID.
> +		 * Preserve input and hidraw on the separate keyboard interface.
> +		 */
> +		if (intf->cur_altsetting->desc.bInterfaceNumber != AMPINEL_DATA_INTERFACE) {
> +			hdev->quirks |= HID_QUIRK_INPUT_PER_APP;
> +			return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
> +		}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260914195759.171524-1-contact@vasily.cc?part=1

  reply	other threads:[~2026-09-14 20:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 19:57 [PATCH] hwmon: (aquacomputer_d5next) Add AMPINEL support Vas Zayarskiy
2026-09-14 20:08 ` sashiko-bot [this message]
2026-09-14 21:59   ` Vas Zayarskiy

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=20260914200831.5642E1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=contact@vasily.cc \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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