From: sashiko-bot@kernel.org
To: "Rong Zhang" <i@rong.moe>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v6 10/13] HID: haptic: Decouple from hid-multitouch and support other devices
Date: Wed, 02 Dec 2026 19:08:06 +0000 [thread overview]
Message-ID: <sashiko-outbox-246527@kernel.org> (raw)
In-Reply-To: <20261203-hid-haptic-kmod-v6-10-95a1273b9e40@rong.moe>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] HID: haptic: stylus matching fails in
hid_haptic_check_prerequisites()
--
commit bd7794227e36fff25c1aaa191f88aebef47dc33b
Author: Rong Zhang <i@rong.moe>
HID: haptic: Decouple from hid-multitouch and support other devices
This commit adds fallback input device selection for hid-haptic so that
haptic devices with Collection Application or Collection Logical
hierarchies can initialize without requiring hid-multitouch integration.
Link: https://usb.org/sites/default/files/hutrr63b_-_haptics_page_redline_0.pdf [1]
Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/input-haptics-implementation-guide [2]
Link: https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/haptic-pen-implementation-guide [3]
> diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c
> index 40bb641fc1f5d..aae4ff1f0ccaa 100644
> --- a/drivers/hid/hid-haptic.c
> +++ b/drivers/hid/hid-haptic.c
[ ... ]
> @@ -566,19 +567,55 @@ static int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device *ha
> static int hid_haptic_check_prerequisites(struct hid_device *hdev,
> struct hid_haptic_device *haptic, struct hid_input *hi)
> {
> + struct hid_report *report;
> +
> if (!haptic->waveform_list_report || !haptic->duration_list_report ||
> !haptic->manual_trigger_report)
> return -ENOENT;
>
> - if (IS_ERR_OR_NULL(haptic->input_dev))
> - return PTR_ERR(haptic->input_dev) ?: -EXDEV;
> -
> /* Check the prerequisites only. */
> if (!hi)
> return 1;
>
> - if (haptic->input_dev == hi->input)
> - return 0;
> + /*
> + * Honor the HID driver's choice.
> + *
> + * If the driver didn't choose an input device or failed its
> + * prerequisites check, initialize the haptic device without the
> + * integration with the driver.
> + */
> + if (IS_ERR_OR_NULL(haptic->input_dev))
> + haptic->input_dev = NULL;
> + else
> + return haptic->input_dev != hi->input;
> +
> + /*
> + * A Simple Haptic Controller may be either a Collection Application
> + * (CA) or a Collection Logical (CL):
> + *
> + * A CA is a dedicated HID application, i.e., not associated with other
> + * HID applications. Choose the first HID input device to attach the FF
> + * device, as other FF drivers do. Haptic Mouse usually falls into this
> + * category.
> + *
> + * A CL is contained within another HID application. The HID input
> + * device handling the manual trigger report must be the one handling
> + * the associated HID application. Haptic Touchpad and Stylus usually
> + * fall into this category.
> + *
> + * When HID_QUIRK_MULTI_INPUT is set, the quirky collection hierarchy
> + * makes no sense anyway, so the first input device is chosen instead.
> + */
> + if (haptic->manual_trigger_report->application == HID_HP_SIMPLECONTROLLER ||
> + hdev->quirks & HID_QUIRK_MULTI_INPUT) {
> + if (list_is_first(&hi->list, &hdev->inputs))
> + return 0;
> + } else {
> + list_for_each_entry(report, &hi->reports, hidinput_list) {
> + if (report == haptic->manual_trigger_report)
> + return 0;
> + }
> + }
[Severity: Medium]
Can this match haptic->manual_trigger_report for a haptic stylus on a
composite touchscreen and pen device bound to hid-multitouch?
In descriptors following the Microsoft Haptic Pen Implementation Guide,
the top-level application collection is HID_DG_PEN, containing a
HID_DG_STYLUS physical collection for the stylus input fields and a
HID_HP_SIMPLECONTROLLER logical collection for the manual trigger output
report.
When hidinput_connect() processes HID_INPUT_REPORT first,
hidinput_allocate() sets hi->application to HID_DG_PEN, and then
mt_input_mapping() overwrites it:
drivers/hid/hid-multitouch.c:mt_input_mapping() {
...
if (field->physical == HID_DG_STYLUS)
hi->application = HID_DG_STYLUS;
...
}
When HID_OUTPUT_REPORT is processed next, manual_trigger_report still has
report->application == HID_DG_PEN. Because mt_probe() sets
HID_QUIRK_INPUT_PER_APP, hidinput_match_application() compares
hidinput->application (now HID_DG_STYLUS) against report->application
(HID_DG_PEN), fails to match the stylus hid_input, and places
manual_trigger_report on a newly allocated hid_input with no input usages.
As a result, manual_trigger_report is absent from the stylus hi->reports
list, hid_haptic_check_prerequisites() returns 1 for the stylus, and the
unpopulated hid_input holding manual_trigger_report is later freed by
hidinput_cleanup_hidinput(), leaving the stylus without haptic force
feedback.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-hid-haptic-kmod-v6-0-95a1273b9e40@rong.moe?part=10
next prev parent reply other threads:[~2026-12-02 19:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 18:33 [PATCH v6 00/13] HID: Add hid-plugin framework & convert hid-haptic into a generic plugin Rong Zhang
2026-12-02 18:33 ` [PATCH v6 01/13] HID: haptic: Get rid of input_ff_destroy() in error paths Rong Zhang
2026-12-02 18:33 ` [PATCH v6 02/13] HID: haptic: Fix use-after-free when draining workqueue Rong Zhang
2026-12-02 18:33 ` [PATCH v6 03/13] HID: haptic, multitouch: Check haptic prerequisite properly Rong Zhang
2026-12-02 18:33 ` [PATCH v6 04/13] HID: haptic: Postpone GET_REPORT to init Rong Zhang
2026-12-02 18:33 ` [PATCH v6 05/13] HID: Add hid-plugin framework for loadable plugin modules Rong Zhang
2026-12-02 18:33 ` [PATCH v6 06/13] HID: haptic: Convert to a loadable plugin module Rong Zhang
2026-12-02 19:07 ` sashiko-bot
2026-12-02 18:33 ` [PATCH v6 07/13] HID: haptic: Adopt pr_fmt, dev_fmt and hid_*() printk helpers Rong Zhang
2026-12-02 18:33 ` [PATCH v6 08/13] HID: Add Ordinal page defines Rong Zhang
2026-12-02 18:33 ` [PATCH v6 09/13] HID: haptic: Handle list reports separately and make auto trigger optional Rong Zhang
2026-12-02 18:33 ` [PATCH v6 10/13] HID: haptic: Decouple from hid-multitouch and support other devices Rong Zhang
2026-12-02 19:08 ` sashiko-bot [this message]
2026-12-02 18:33 ` [PATCH v6 11/13] HID: haptic: Add quirk table Rong Zhang
2026-12-02 18:33 ` [PATCH v6 12/13] HID: haptic: Add HID_HAPTIC_QUIRK_NO_RETRIGGER to disable retriggering Rong Zhang
2026-12-02 18:33 ` [PATCH v6 13/13] HID: haptic: Add quirk flag for Logitech MX Master 4 Rong Zhang
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-246527@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=i@rong.moe \
--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