Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Denis Benato" <denis.benato@linux.dev>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v14 01/18] HID: asus: size feature reports from the HID report descriptor
Date: Fri, 06 Nov 2026 14:51:21 +0000	[thread overview]
Message-ID: <sashiko-outbox-201618@kernel.org> (raw)
In-Reply-To: <20261106142334.1881-2-denis.benato@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] HID: asus: report type mismatch in asus_has_report_id() and
  asus_report_len()
--

commit a49f4ba7e2479238fb06ec5527d0ef52ccd84b83
Author: Denis Benato <denis.benato@linux.dev>

HID: asus: size feature reports from the HID report descriptor

This commit derives feature report transfer lengths from the device's HID
report descriptor via asus_report_len() instead of using hardcoded report
sizes.

> diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
> index f6aa1be09ad53..46643022b68d0 100644
> --- a/drivers/hid/hid-asus.c
> +++ b/drivers/hid/hid-asus.c
[ ... ]
> +static size_t asus_report_len(struct hid_device *hdev, u8 report_id)
> +{
> +	struct hid_report *report;
> +
> +	report = asus_find_report(hdev, HID_FEATURE_REPORT, report_id);
> +
> +	return report ? hid_report_len(report) : 0;
> +}
[ ... ]
> @@ -604,8 +687,13 @@ static int asus_kbd_init(struct hid_device *hdev, u8 report_id)
>  	 */
>  	const u8 buf[] = { report_id, 0x41, 0x53, 0x55, 0x53, 0x20, 0x54,
>  		     0x65, 0x63, 0x68, 0x2e, 0x49, 0x6e, 0x63, 0x2e, 0x00 };
> +	size_t hw_len = asus_report_len(hdev, report_id);
> +	size_t cmp_len;
>  	int ret;
>  
> +	if (!hw_len)
> +		return -EINVAL;
[ ... ]
> @@ -958,17 +1054,12 @@ static void validate_mcu_fw_version(struct hid_device *hdev, int idProduct)
>  
>  static bool asus_has_report_id(struct hid_device *hdev, u16 report_id)
>  {
> -	struct hid_report *report;
> -	int t;
> +	if (report_id >= HID_MAX_IDS)
> +		return false;
>  
> -	for (t = HID_INPUT_REPORT; t <= HID_FEATURE_REPORT; t++) {
> -		list_for_each_entry(report, &hdev->report_enum[t].report_list, list) {
> -			if (report->id == report_id)
> -				return true;
> -		}
> -	}
> -
> -	return false;
> +	return asus_find_report(hdev, HID_INPUT_REPORT, report_id) ||
> +	       asus_find_report(hdev, HID_OUTPUT_REPORT, report_id) ||
> +	       asus_find_report(hdev, HID_FEATURE_REPORT, report_id);
>  }

[Severity: Medium]
Should asus_has_report_id() and asus_report_len() check the same report
types?

asus_has_report_id() matches HID_INPUT_REPORT, HID_OUTPUT_REPORT, and
HID_FEATURE_REPORT, and its callers gate feature-report operations such as
asus_initialize_reports() -> asus_kbd_init():

drivers/hid/hid-asus.c:asus_initialize_reports() {
	for (int r = 0; r < ARRAY_SIZE(asus_report_id_init); r++) {
		if (asus_has_report_id(hdev, asus_report_id_init[r])) {
			ret = asus_kbd_init(hdev, asus_report_id_init[r]);
			if (ret < 0)
				hid_warn(hdev, "Failed to initialize 0x%x: %d.\n",
					 asus_report_id_init[r], ret);
		}
	}
}

However, asus_report_len() only checks HID_FEATURE_REPORT and returns 0
otherwise.  On devices whose descriptor declares report 0x5a only as an
input report (such as keyboards using QUIRK_G752_KEYBOARD, where the fixed
descriptor in asus_report_fixup() only defines an Input item for report
0x5a), asus_has_report_id() returns true while asus_kbd_init() now fails
with -EINVAL and logs a warning on probe and reset_resume.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261106142334.1881-1-denis.benato@linux.dev?part=1

  reply	other threads:[~2026-11-06 14:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 14:23 [PATCH v14 00/18] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-11-06 14:23 ` [PATCH v14 01/18] HID: asus: size feature reports from the HID report descriptor Denis Benato
2026-11-06 14:51   ` sashiko-bot [this message]
2026-11-06 14:23 ` [PATCH v14 02/18] HID: asus: add support for ROG Ally handhelds Denis Benato
2026-11-06 14:51   ` sashiko-bot
2026-11-06 14:23 ` [PATCH v14 03/18] HID: asus: add gamepad configuration Denis Benato
2026-11-06 14:23 ` [PATCH v14 04/18] HID: asus: add vibration strength configuration Denis Benato
2026-11-06 14:23 ` [PATCH v14 05/18] HID: asus: add joysticks inner and outer range configuration Denis Benato
2026-11-06 14:23 ` [PATCH v14 06/18] HID: asus: add triggers " Denis Benato
2026-11-06 14:23 ` [PATCH v14 07/18] HID: asus: add joysticks anti-deadzone configuration Denis Benato
2026-11-06 14:23 ` [PATCH v14 08/18] HID: asus: add support for response curve Denis Benato
2026-11-06 14:23 ` [PATCH v14 09/18] HID: asus: add support to force feedback Denis Benato
2026-11-06 14:23 ` [PATCH v14 10/18] HID: asus: add support for gamepad mode Denis Benato
2026-11-06 14:23 ` [PATCH v14 11/18] HID: asus: add support for turbo buttons Denis Benato
2026-11-06 14:42   ` sashiko-bot
2026-11-06 14:23 ` [PATCH v14 12/18] HID: asus: add support for btn remapping Denis Benato
2026-11-06 14:46   ` sashiko-bot
2026-11-06 14:23 ` [PATCH v14 13/18] HID: asus: identify XG Mobile stations and bind the LED to the reported model Denis Benato
2026-11-06 14:23 ` [PATCH v14 14/18] HID: asus: expose XG Mobile identity and firmware information Denis Benato
2026-11-06 14:23 ` [PATCH v14 15/18] HID: asus: document ROG XG Mobile sysfs attributes Denis Benato
2026-11-06 14:23 ` [PATCH v14 16/18] HID: asus: document ROG Ally " Denis Benato
2026-11-06 14:23 ` [PATCH v14 17/18] platform/x86: asus-armoury: pick the eGPU activation from the reported GPU Denis Benato
2026-11-06 14:23 ` [PATCH v14 18/18] MAINTAINERS: add maintainer for the ASUS HID driver Denis Benato

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=sashiko-outbox-201618@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=denis.benato@linux.dev \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@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