From: sashiko-bot@kernel.org
To: "Erik Håkansson" <erikhakan@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH RFC 2/4] HID: logitech: handle HID++ thumbwheel reports
Date: Fri, 02 Oct 2026 09:14:01 +0000 [thread overview]
Message-ID: <20261002091401.C17011F00899@smtp.kernel.org> (raw)
In-Reply-To: <20261002-bolt-input-rfc-v1-2-333e1f350586@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] hid: logitech-hidpp: divide-by-zero in thumbwheel scroll due to unprotected memset
- [Medium] hid: logitech-hidpp: M560 vertical scroll dropped on init failure
--
commit 67886caf8cb1bbca1343ff56109a68fec18fa393
Author: Erik Håkansson <erikhakan@gmail.com>
HID: logitech: handle HID++ thumbwheel reports
This commit adds support for HID++ thumbwheel reports for devices with the
0x2150 feature and generalizes scroll handling. For Bolt devices, it defaults
to diverting thumbwheel reports to HID++ to get device index support.
> diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
> index ff6a1095e7ba9..464685ad21bbc 100644
> --- a/drivers/hid/hid-logitech-hidpp.c
> +++ b/drivers/hid/hid-logitech-hidpp.c
[ ... ]
> @@ -3323,7 +3391,8 @@ static int m560_raw_event(struct hid_device *hdev, u8 *data, int size)
> v = sign_extend32(data[6], 7);
> if (v != 0)
> hidpp_scroll_counter_handle_scroll(hidpp->input,
> - &hidpp->vertical_wheel_counter, v);
> + &hidpp->vertical_wheel_counter, v,
> + REL_WHEEL_HI_RES, REL_WHEEL);
[Severity: Medium]
When high-resolution scroll initialization fails, scale_denominator remains
zero. In this scenario, hidpp_scroll_counter_handle_scroll() will return
false. Does this code need a fallback path to ensure standard low-resolution
scroll events are still reported instead of silently dropping the vertical
scroll completely?
>
> input_sync(hidpp->input);
> }
[ ... ]
> @@ -4033,6 +4105,49 @@ static int hidpp_initialize_hires_scroll(struct hidpp_device *hidpp)
> return 0;
> }
>
> +static void thumbwheel_scroll_enable(struct hidpp_device *hidpp)
> +{
> + bool divert;
> + int ret;
> +
> + memset(&hidpp->thumbwheel_counter, 0,
> + sizeof(hidpp->thumbwheel_counter));
[Severity: High]
Can this memset() race with hidpp20_thumbwheel_raw_event() in softirq context?
If a wireless device wakes from sleep, hidpp_connect_event() could be queued
in a worker thread, calling thumbwheel_scroll_enable().
If the user scrolls concurrently, hidpp20_thumbwheel_raw_event() might
evaluate the scale_denominator check using the old counter value:
if (!hidpp->input || !hidpp->thumbwheel_counter.scale_numerator ||
!hidpp->thumbwheel_counter.scale_denominator)
return 1;
And then the worker thread zeroes the struct just before it is used in
hidpp_scroll_counter_handle_scroll():
scaled = div_s64((s64)value * 120 * counter->scale_numerator,
counter->scale_denominator);
Could this result in a divide-by-zero kernel panic?
> + ret = hidpp_thumbwheel_get_info(hidpp,
> + &hidpp->thumbwheel_counter.scale_numerator,
> + &hidpp->thumbwheel_counter.scale_denominator,
> + &hidpp->thumbwheel_positive_right);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261002-bolt-input-rfc-v1-0-333e1f350586@gmail.com?part=2
next prev parent reply other threads:[~2026-10-02 9:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 22:23 [PATCH RFC 0/4] HID: logitech: add Bolt support with HID++ input handling Erik Håkansson
2026-10-01 22:23 ` [PATCH RFC 1/4] HID: logitech: add Bolt receiver support Erik Håkansson
2026-10-01 22:23 ` [PATCH RFC 2/4] HID: logitech: handle HID++ thumbwheel reports Erik Håkansson
2026-10-02 9:14 ` sashiko-bot [this message]
2026-10-01 22:23 ` [PATCH RFC 3/4] HID: logitech: divert M650 side buttons over Bolt Erik Håkansson
2026-10-01 22:23 ` [PATCH RFC 4/4] HID: logitech-hidpp: support ratchet wheel Erik Håkansson
2026-10-02 9:13 ` 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=20261002091401.C17011F00899@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=erikhakan@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