Linux Input/HID development
 help / color / mirror / Atom feed
From: Paolo Pisati <p.pisati@gmail.com>
To: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <bentiss@kernel.org>,
	linux-input@vger.kernel.org
Subject: [PATCH 4/7] hid-asus: Remove more bogus zero bytes from some report descriptors
Date: Wed, 13 May 2026 18:32:45 +0200	[thread overview]
Message-ID: <20260513163248.16483-5-p.pisati@gmail.com> (raw)
In-Reply-To: <20260513163248.16483-1-p.pisati@gmail.com>

From: Joshua Leivenzon <hacker1024@users.sourceforge.net>

Signed-off-by: Joshua Leivenzon <hacker1024@users.sourceforge.net>
---
 drivers/hid/hid-asus.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 2a88ce695489d..cf9184ed2d3ec 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -1422,14 +1422,19 @@ static const __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 		/*
 		 * Change Usage (76h) to Usage Minimum (00h), Usage Maximum
 		 * (FFh) and clear the flags in the Input() byte.
-		 * Note the descriptor has a bogus 0 byte at the end so we
-		 * only need 1 extra byte.
 		 */
 		if (*rsize == rsize_orig &&
 			rdesc[offs] == 0x09 && rdesc[offs + 1] == 0x76) {
 			__u8 *new_rdesc;
+            unsigned int new_rsize = rsize_orig;
 
-			new_rdesc = devm_kzalloc(&hdev->dev, rsize_orig + 1,
+			/* Clear bogus trailing zero bytes. */
+			while (rdesc[new_rsize + 1] == 0)
+				--new_rsize;
+            /* Make room for the added bytes. */
+			new_rsize += 2;
+
+            new_rdesc = devm_kzalloc(&hdev->dev, new_rsize,
 						 GFP_KERNEL);
 			if (!new_rdesc)
 				return rdesc;
@@ -1439,8 +1444,8 @@ static const __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 				"T100CHI" : drvdata->quirks & QUIRK_T90CHI ?
 				"T90CHI" : "ZENBOOK DUO");
 
-			memcpy(new_rdesc, rdesc, rsize_orig);
-			*rsize = rsize_orig + 1;
+			memcpy(new_rdesc, rdesc, new_rsize);
+			*rsize = new_rsize;
 			rdesc = new_rdesc;
 
 			memmove(rdesc + offs + 4, rdesc + offs + 2, 12);
-- 
2.53.0


  parent reply	other threads:[~2026-05-13 16:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 16:32 [PATCH 0/7] ASUS Zenbook Duo keyboard support Paolo Pisati
2026-05-13 16:32 ` [PATCH 1/7] hid-asus: Fix up Zenbook Duo report descriptors Paolo Pisati
2026-05-14  6:50   ` sashiko-bot
2026-05-13 16:32 ` [PATCH 2/7] hid-asus: Add missing Zenbook Duo hotkeys Paolo Pisati
2026-05-14  7:49   ` sashiko-bot
2026-05-13 16:32 ` [PATCH 3/7] hid-asus: Add report descriptor fixup offsets for UX8406MA USB keyboard Paolo Pisati
2026-05-13 16:32 ` Paolo Pisati [this message]
2026-05-14  8:57   ` [PATCH 4/7] hid-asus: Remove more bogus zero bytes from some report descriptors sashiko-bot
2026-05-13 16:32 ` [PATCH 5/7] hid-asus: Fix input mapping on dedicated vendor HID interfaces Paolo Pisati
2026-05-14 10:32   ` sashiko-bot
2026-05-13 16:32 ` [PATCH 6/7] hid-asus: Allow adding custom hotkey handler logic Paolo Pisati
2026-05-14 11:14   ` sashiko-bot
2026-05-13 16:32 ` [PATCH 7/7] hid-asus: add prod-id, quirk for Zenbook Duo keyboard Paolo Pisati
2026-05-14 12:03   ` sashiko-bot

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=20260513163248.16483-5-p.pisati@gmail.com \
    --to=p.pisati@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    /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