All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Haobo Cheng <i@4t.pw>
Cc: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org,
	 gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: typec: mux: initialize orientation switch array
Date: Wed, 5 Aug 2026 02:28:13 +0200	[thread overview]
Message-ID: <anKDIaz2GWjdm2U0@venus> (raw)
In-Reply-To: <20260804083434.20885-1-i@4t.pw>

[-- 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 --]

      reply	other threads:[~2026-08-05  0:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04  8:34 [PATCH] usb: typec: mux: initialize orientation switch array Haobo Cheng
2026-08-05  0:28 ` Sebastian Reichel [this message]

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=anKDIaz2GWjdm2U0@venus \
    --to=sebastian.reichel@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=i@4t.pw \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.