* [PATCH] usb: typec: ucsi: skip connector validation before init
@ 2026-04-07 6:39 Nathan Rebello
2026-04-07 6:52 ` Takashi Iwai
2026-04-07 12:26 ` Heikki Krogerus
0 siblings, 2 replies; 3+ messages in thread
From: Nathan Rebello @ 2026-04-07 6:39 UTC (permalink / raw)
To: gregkh, heikki.krogerus
Cc: linux-usb, linux-kernel, tiwai, stable, Nathan Rebello
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",
--
2.43.0.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: typec: ucsi: skip connector validation before init
2026-04-07 6:39 [PATCH] usb: typec: ucsi: skip connector validation before init Nathan Rebello
@ 2026-04-07 6:52 ` Takashi Iwai
2026-04-07 12:26 ` Heikki Krogerus
1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2026-04-07 6:52 UTC (permalink / raw)
To: Nathan Rebello
Cc: gregkh, heikki.krogerus, linux-usb, linux-kernel, tiwai, stable
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: typec: ucsi: skip connector validation before init
2026-04-07 6:39 [PATCH] usb: typec: ucsi: skip connector validation before init Nathan Rebello
2026-04-07 6:52 ` Takashi Iwai
@ 2026-04-07 12:26 ` Heikki Krogerus
1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2026-04-07 12:26 UTC (permalink / raw)
To: Nathan Rebello; +Cc: gregkh, linux-usb, linux-kernel, tiwai, stable
On Tue, Apr 07, 2026 at 02:39:58AM -0400, 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>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.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",
> --
> 2.43.0.windows.1
--
heikki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-07 12:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-07 6:39 [PATCH] usb: typec: ucsi: skip connector validation before init Nathan Rebello
2026-04-07 6:52 ` Takashi Iwai
2026-04-07 12:26 ` Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox