Re: [PATCH] usb: typec: mux: initialize orientation switch array

Sebastian Reichel <[email protected]>
Newsgroups org.kernel.vger.linux-kernel,org.kernel.vger.linux-usb
Message-ID <anKDIaz2GWjdm2U0@venus>
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 <[email protected]>
> ---

oops.

Cc: [email protected]
Reviewed-by: Sebastian Reichel <[email protected]>

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
>
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmpyg5kACgkQ2O7X88g7
+prxDg/9Gj7tPq1JUFQjoy7Do4Af/HiHKkAPoprqmMUSxKPxyitmT4k6Hgjp8z13
hCX1hXZIgDujTq+J4B0QaXOTLRmzZR8Z2S3DN0gcEnm4xq+0pWfPzpv+WwTsczfA
Nzob5WMgtLBL8grYR3WUlP+2CF8eLigaLy6HI8Ac9sjrh6YQ4y/vEZbQeLmFKjha
O2QjL60W1AMvK6Cses1AzXNFHe27DEa2YqnetZxNTUZiHTrjPpE3DO30MuY2PAR8
8hy+k5MeorfntKcxws8qiVZbXdL5FQDIM3riideniwhBXKZ5jO+X+Rv0p4hnq7iY
g6wFaz1Ra1ajyW3a+eMTVXJE6NccWoT0bTe+sLQRo+ef4egscUV2KdP/7opVr0ru
4+kaMShkzdY3y4jvyvZ90SPAWZXOpyerDmTs1Y7Eoh17GA6uCVNMTnA3ib/9ZrYj
s6An3lTAhllshxv9Tw3k1V0fOsGToDjdi+uTTR4JlrKTyRpCaG5PDT9sx0902fe4
QEe6Lz6D13axMhvp06S6FRfV2JjRbOeusWDHjn0gbYyLqFZxeL9W9lyn8zOgIAwb
MNcQD65fV+rZMFcyGcsQVeUaNhJdl2KUcWn6tKHOGDhe/abW4mv1SO0W3ou0gcaB
cDM1BDZGO+fHFCAYjfq/U3ullhs/XAr7dDbGJAxPb7dzIeoNhoo=
=qk85
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.