All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Nathan Rebello <nathan.c.rebello@gmail.com>
Cc: gregkh@linuxfoundation.org, heikki.krogerus@linux.intel.com,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	tiwai@suse.de, stable@vger.kernel.org
Subject: Re: [PATCH] usb: typec: ucsi: skip connector validation before init
Date: Tue, 07 Apr 2026 08:52:55 +0200	[thread overview]
Message-ID: <878qazntx4.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260407063958.863-1-nathan.c.rebello@gmail.com>

On Tue, 07 Apr 2026 08:39:58 +0200,
Nathan Rebello wrote:
> 
> Notifications can arrive before ucsi_init() has populated
> ucsi->cap.num_connectors via GET_CAPABILITY. At that point
> num_connectors is still 0, causing all valid connector numbers to be
> incorrectly rejected as bogus.
> 
> Skip the bounds check when num_connectors is 0 (not yet initialized).
> Pre-init notifications are already handled safely by the early-event
> guard in ucsi_connector_change().
> 
> Reported-by: Takashi Iwai <tiwai@suse.de>
> Fixes: d2d8c17ac01a ("usb: typec: ucsi: validate connector number in ucsi_notify_common()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Nathan Rebello <nathan.c.rebello@gmail.com>
> ---
>  drivers/usb/typec/ucsi/ucsi.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index b77910152399..7df3a7b94a40 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -43,7 +43,8 @@ void ucsi_notify_common(struct ucsi *ucsi, u32 cci)
>  		return;
>  
>  	if (UCSI_CCI_CONNECTOR(cci)) {
> -		if (UCSI_CCI_CONNECTOR(cci) <= ucsi->cap.num_connectors)
> +		if (!ucsi->cap.num_connectors ||
> +		    UCSI_CCI_CONNECTOR(cci) <= ucsi->cap.num_connectors)
>  			ucsi_connector_change(ucsi, UCSI_CCI_CONNECTOR(cci));
>  		else
>  			dev_err(ucsi->dev, "bogus connector number in CCI: %lu\n",

Confirmed that it fixes my case.

Tested-by: Takashi Iwai <tiwai@suse.de>


Thanks!

Takashi

  reply	other threads:[~2026-04-07  6:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07  6:39 [PATCH] usb: typec: ucsi: skip connector validation before init Nathan Rebello
2026-04-07  6:52 ` Takashi Iwai [this message]
2026-04-07 12:26 ` Heikki Krogerus

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=878qazntx4.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=nathan.c.rebello@gmail.com \
    --cc=stable@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.