From: Rafael Passos <rafael@rcpassos.me>
To: bentiss@kernel.org, david@readahead.eu, jikos@kernel.org
Cc: jkoolstra@xs4all.nl, Rafael Passos <rafael@rcpassos.me>,
linux-input@vger.kernel.org
Subject: [PATCH v2 0/4] HID: wiimote: new LED behavior on connect, scoped guards, uaf
Date: Wed, 15 Jul 2026 18:24:52 -0300 [thread overview]
Message-ID: <20260715212501.3920033-1-rafael@rcpassos.me> (raw)
Hi,
This patchset contains one feature change, and two cleanup patches.
The feature is turning different LEDs for each of the first 4 wiimotes connected.
From id 5 forward, the LED will cycle back to 1, and so on.
This uses the ida struct, so its quite simple and lightweight.
The hid_info log message prints out the controller id.
While implementing this feature, I decided to cleanup the code using
scoped_guard for the many spinlocks in the driver. There are two places
where the original lock/unlock version fits best, and I left them
untouched.
Lastly, I used the __free scope cleanup in the wiimote and LED probe functions.
The LED is trivial. The wiimote_probe required a new state tracker bitmask.
It was really fun working with this driver.
I tested it with 4 Wii Motion Plus remotes (gen2).
Video recording of my tests (48s video).
https://rcpassos.me/video/wiimote-led-linux-driver
Thanks,
Rafael Passos
---
V1: https://lore.kernel.org/linux-input/20260710153456.2093889-1-rafael@rcpassos.me/
Changes from v1:
(1/3):
- fix ida_alloc_min error handling to consider negative values
- remove fallback to 1 on ida_alloc_min failure
- move player_leds static array to hid-wiimote-core.c
- s/instance_id/player_id/g
- store player_id on an u8
(2/3):
- add header include for cleanup.h
- add identation to one-liner scoped_guards
(3/3):
- add scoped cleanup function to wiimote_probe, with a bitmask to track state
(I will also send in response to this patch, what I used to test it).
(4/4) *new patch* :
- sashiko found a pre-existing uaf. Unlikely, but correct.
implemented using the playstation driver as an inspiration
Rafael Passos (4):
HID: wiimote: turn on the LEDs indicating the controller id
HID: wiimote: replace spinlock pairs with scoped_guard
HID: wiimote: use scoped cleanup in wiimote and led probes
HID: wiimote: fix uaf when hid events are handled during destroy
drivers/hid/hid-wiimote-core.c | 335 ++++++++++++++++--------------
drivers/hid/hid-wiimote-debug.c | 50 ++---
drivers/hid/hid-wiimote-modules.c | 24 +--
drivers/hid/hid-wiimote.h | 2 +
4 files changed, 215 insertions(+), 196 deletions(-)
--
2.53.0
next reply other threads:[~2026-07-15 21:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 21:24 Rafael Passos [this message]
2026-07-15 21:24 ` [PATCH v2 1/4] HID: wiimote: turn on the LEDs indicating the controller id Rafael Passos
2026-07-15 21:48 ` sashiko-bot
2026-07-15 21:24 ` [PATCH v2 2/4] HID: wiimote: replace spinlock pairs with scoped_guard Rafael Passos
2026-07-15 21:39 ` sashiko-bot
2026-07-15 21:24 ` [PATCH v2 3/4] HID: wiimote: use scoped cleanup in wiimote and led probes Rafael Passos
2026-07-15 21:35 ` [TEST] Patch used for testing the wiimote_probe_cleanup Rafael Passos
2026-07-15 21:42 ` [PATCH v2 3/4] HID: wiimote: use scoped cleanup in wiimote and led probes sashiko-bot
2026-07-15 21:24 ` [PATCH v2 4/4] HID: wiimote: fix uaf when hid events are handled during destroy Rafael Passos
2026-07-15 21:57 ` 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=20260715212501.3920033-1-rafael@rcpassos.me \
--to=rafael@rcpassos.me \
--cc=bentiss@kernel.org \
--cc=david@readahead.eu \
--cc=jikos@kernel.org \
--cc=jkoolstra@xs4all.nl \
--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