Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] HID: nintendo: release the player ID when LED setup fails
@ 2026-09-21 18:49 Sang-Hoon Choi
  0 siblings, 0 replies; only message in thread
From: Sang-Hoon Choi @ 2026-09-21 18:49 UTC (permalink / raw)
  To: Daniel J. Ogorchock
  Cc: Jiri Kosina, Benjamin Tissoires, linux-input, Changyul Lee

joycon_leds_create() allocates a player ID before allocating the LED
names and registering the LEDs. If one of those later steps fails,
nintendo_hid_probe() jumps to err_io_stop and skips the ID cleanup.
The failed probe leaves the allocated ID in nintendo_player_id_allocator.

Use err_ida for this failure, as the power supply and input setup error
paths already do. If the ID allocation itself failed, player_id is
U32_MAX and ida_free() leaves the allocator untouched.

Fixes: 5307de63d71d ("HID: nintendo: use ida for LED player id")
Reported-by: Changyul Lee <lcy8047@gmail.com>
Assisted-by: LLM
Signed-off-by: Sang-Hoon Choi <csh0052@gmail.com>
---
Found during source review at mainline
5dd1818b15d98d4a20806cd00b1b40320b06004f. The affected source is unchanged
at f0100363d8c374bd8e9ea7c9ba02744f0b802ca4.

The modified hid-nintendo.o compiled with x86 allmodconfig and W=1.
I have not tested this on a controller or injected LED setup failures.

diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
index 43e0f2aae..bec0e7652 100644
--- a/drivers/hid/hid-nintendo.c
+++ b/drivers/hid/hid-nintendo.c
@@ -2784,7 +2784,7 @@ static int nintendo_hid_probe(struct hid_device *hdev,
 	ret = joycon_leds_create(ctlr);
 	if (ret) {
 		hid_err(hdev, "Failed to create leds; ret=%d\n", ret);
-		goto err_io_stop;
+		goto err_ida;
 	}
 
 	/* Initialize the battery power supply */

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-21 18:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-21 18:49 [PATCH] HID: nintendo: release the player ID when LED setup fails Sang-Hoon Choi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox