Commit 5a114040 authored by Nathan Rebello's avatar Nathan Rebello Committed by Greg Kroah-Hartman
Browse files

usb: typec: ucsi: skip connector validation before init



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: default avatarTakashi Iwai <tiwai@suse.de>
Fixes: d2d8c17a ("usb: typec: ucsi: validate connector number in ucsi_notify_common()")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarNathan Rebello <nathan.c.rebello@gmail.com>
Tested-by: default avatarTakashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260407063958.863-1-nathan.c.rebello@gmail.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 591cd656
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -44,7 +44,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",