* [PATCH] usb: typec: mux: initialize orientation switch array
@ 2026-08-04 8:34 Haobo Cheng
2026-08-05 0:28 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Haobo Cheng @ 2026-08-04 8:34 UTC (permalink / raw)
To: heikki.krogerus, linux-usb
Cc: gregkh, sebastian.reichel, linux-kernel, Haobo Cheng
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: typec: mux: initialize orientation switch array
2026-08-04 8:34 [PATCH] usb: typec: mux: initialize orientation switch array Haobo Cheng
@ 2026-08-05 0:28 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2026-08-05 0:28 UTC (permalink / raw)
To: Haobo Cheng; +Cc: heikki.krogerus, linux-usb, gregkh, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1489 bytes --]
Hi,
On Tue, Aug 04, 2026 at 04:34:34PM +0800, Haobo Cheng wrote:
> 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>
> ---
oops.
Cc: stable@vger.kernel.org
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Greetings,
-- Sebastian
> 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
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-05 0:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04 8:34 [PATCH] usb: typec: mux: initialize orientation switch array Haobo Cheng
2026-08-05 0:28 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox