From: Ryan McClelland <rymcclel@gmail.com>
To: vi@endrift.com, dmitry.torokhov@gmail.com, jikos@kernel.org,
bentiss@kernel.org, linux-input@vger.kernel.org
Cc: s.jegen@gmail.com, Ryan McClelland <rymcclel@gmail.com>
Subject: [PATCH] HID: nintendo: fix clang build of switch2_probe guard/goto
Date: Mon, 22 Jun 2026 02:47:28 -0700 [thread overview]
Message-ID: <20260622095303.837361-1-rymcclel@gmail.com> (raw)
In-Reply-To: <20260512200051.2534081-2-vi@endrift.com>
clang rejects the forward `goto err_close/err_stop` in switch2_probe()
because they jump across the scope of the `guard(mutex)(&ns2->lock)`
cleanup variable ("cannot jump from this goto statement to its label").
All three early error paths run before the lock is acquired, so replace
the gotos with explicit hid_hw_close()/hid_hw_stop() cleanup and drop the
now-unused labels. No functional change; gcc accepted the original.
Signed-off-by: Ryan McClelland <rymcclel@gmail.com>
---
Hi Vicki, I've been testing your Switch 2 series on a local machine here
with JC2, GC, and Pro all over USB and hits this clang build break, Patch below
, feel free to just squash it in.
drivers/hid/hid-nintendo.c:4147:3: error: cannot jump from this goto
statement to its label
drivers/hid/hid-nintendo.c:4153:3: error: cannot jump from this goto
statement to its label
with the explanatory notes pointing at:
note: jump bypasses initialization of variable with __attribute__((cleanup))
guard(mutex)(&ns2->lock);
drivers/hid/hid-nintendo.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
index 40f57036d810..6a286d49e5bd 100644
--- a/drivers/hid/hid-nintendo.c
+++ b/drivers/hid/hid-nintendo.c
@@ -4144,13 +4144,16 @@ static int switch2_probe(struct hid_device *hdev, const struct hid_device_id *id
ret = hid_hw_open(hdev);
if (ret) {
hid_err(hdev, "hw_open failed %d\n", ret);
- goto err_stop;
+ hid_hw_stop(hdev);
+ return ret;
}
ns2 = switch2_get_controller(phys);
if (IS_ERR(ns2)) {
ret = PTR_ERR(ns2);
- goto err_close;
+ hid_hw_close(hdev);
+ hid_hw_stop(hdev);
+ return ret;
}
guard(mutex)(&ns2->lock);
@@ -4194,13 +4197,6 @@ static int switch2_probe(struct hid_device *hdev, const struct hid_device_id *id
return switch2_init_controller(ns2);
return 0;
-
-err_close:
- hid_hw_close(hdev);
-err_stop:
- hid_hw_stop(hdev);
-
- return ret;
}
static void switch2_remove(struct hid_device *hdev)
--
2.54.0
next prev parent reply other threads:[~2026-06-22 9:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 20:00 [PATCH v5 0/3] HID: nintendo: Add preliminary Switch 2 controller driver Vicki Pfau
2026-05-12 20:00 ` [PATCH v5 1/3] " Vicki Pfau
2026-05-14 0:15 ` sashiko-bot
2026-05-23 8:57 ` Silvan Jegen
2026-06-19 4:02 ` Vicki Pfau
2026-06-19 3:56 ` Vicki Pfau
2026-06-22 9:47 ` Ryan McClelland [this message]
2026-05-12 20:00 ` [PATCH v5 2/3] HID: nintendo: Add rumble support for Switch 2 controllers Vicki Pfau
2026-05-14 0:53 ` sashiko-bot
2026-05-30 20:03 ` Silvan Jegen
2026-06-19 4:17 ` Vicki Pfau
2026-05-12 20:00 ` [PATCH v5 3/3] HID: nintendo: Add unified report format support Vicki Pfau
2026-05-14 1:06 ` sashiko-bot
2026-05-31 17:57 ` Silvan Jegen
2026-06-10 16:18 ` [PATCH v5 0/3] HID: nintendo: Add preliminary Switch 2 controller driver Jiri Kosina
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=20260622095303.837361-1-rymcclel@gmail.com \
--to=rymcclel@gmail.com \
--cc=bentiss@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=s.jegen@gmail.com \
--cc=vi@endrift.com \
/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