From: Haobo Cheng <i@4t.pw>
To: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org
Cc: gregkh@linuxfoundation.org, sebastian.reichel@collabora.com,
linux-kernel@vger.kernel.org, Haobo Cheng <i@4t.pw>
Subject: [PATCH] usb: typec: mux: initialize orientation switch array
Date: Tue, 4 Aug 2026 16:34:34 +0800 [thread overview]
Message-ID: <20260804083434.20885-1-i@4t.pw> (raw)
Commit a53b4f9c51a9 ("usb: typec: mux: avoid duplicated orientation
switches") started using the orientation switch result array as state for
duplicate detection, but left the array uninitialized.
The first match therefore scans indeterminate stack contents before any
result has been stored. A valid orientation switch may be incorrectly
discarded as a duplicate, causing fwnode_typec_switch_get() to return no
switch.
Zero-initialize the array before collecting matches.
Fixes: a53b4f9c51a9 ("usb: typec: mux: avoid duplicated orientation switches")
Signed-off-by: Haobo Cheng <i@4t.pw>
---
drivers/usb/typec/mux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c
index 9b908c46b..55dab1c76 100644
--- a/drivers/usb/typec/mux.c
+++ b/drivers/usb/typec/mux.c
@@ -79,7 +79,7 @@ static void *typec_switch_match(const struct fwnode_handle *fwnode,
*/
struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode)
{
- struct typec_switch_dev *sw_devs[TYPEC_MUX_MAX_DEVS];
+ struct typec_switch_dev *sw_devs[TYPEC_MUX_MAX_DEVS] = { };
struct typec_switch *sw;
int count;
int err;
--
2.53.0
next reply other threads:[~2026-08-04 8:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 8:34 Haobo Cheng [this message]
2026-08-05 0:28 ` [PATCH] usb: typec: mux: initialize orientation switch array Sebastian Reichel
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=20260804083434.20885-1-i@4t.pw \
--to=i@4t.pw \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sebastian.reichel@collabora.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