Linux Input/HID development
 help / color / mirror / Atom feed
From: Sang-Hoon Choi <csh0052@gmail.com>
To: "Daniel J. Ogorchock" <djogorchock@gmail.com>
Cc: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <bentiss@kernel.org>,
	linux-input@vger.kernel.org, Changyul Lee <lcy8047@gmail.com>
Subject: [PATCH] HID: nintendo: release the player ID when LED setup fails
Date: Tue, 22 Sep 2026 03:49:28 +0900	[thread overview]
Message-ID: <179001656825.91284.1468613120745540918.idr-bug-07@gmail.com> (raw)

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 */

                 reply	other threads:[~2026-09-21 18:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=179001656825.91284.1468613120745540918.idr-bug-07@gmail.com \
    --to=csh0052@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=djogorchock@gmail.com \
    --cc=jikos@kernel.org \
    --cc=lcy8047@gmail.com \
    --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