From: Hongbo Li <lihongbo22@huawei.com>
To: <heikki.krogerus@linux.intel.com>, <nathan.c.rebello@gmail.com>
Cc: <gregkh@linuxfoundation.org>, <kyungtae.kim@dartmouth.edu>,
<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<lihongbo22@huawei.com>
Subject: [PATCH 6.6 & 5.10] usb: typec: ucsi: validate connector number in ucsi_connector_change
Date: Fri, 8 May 2026 17:20:26 +0800 [thread overview]
Message-ID: <20260508092026.1364820-1-lihongbo22@huawei.com> (raw)
Commit d2d8c17ac01a ("usb: typec: ucsi: validate connector
number in ucsi_notify_common()") and commit 5a1140404cbf ("usb:
typec: ucsi: skip connector validation before init") add the bounds
check when do the connector change both in pre-init notification and
the forward notifications. But they are difficult to backport to
early stable branch such as LTS 6.6, LTS 5.10 due to many dependencies.
Instead, we choose to validate connector number in ucsi_connector_change
directly to avoid out-of-range issue.
Fixes: bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
drivers/usb/typec/ucsi/ucsi.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index b88f4e179a7a..4f5a72a1fbd8 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -960,13 +960,20 @@ static void ucsi_handle_connector_change(struct work_struct *work)
*/
void ucsi_connector_change(struct ucsi *ucsi, u8 num)
{
- struct ucsi_connector *con = &ucsi->connector[num - 1];
+ struct ucsi_connector *con;
if (!(ucsi->ntfy & UCSI_ENABLE_NTFY_CONNECTOR_CHANGE)) {
dev_dbg(ucsi->dev, "Early connector change event\n");
return;
}
+ if (ucsi->cap.num_connectors && num > ucsi->cap.num_connectors) {
+ dev_err(ucsi->dev, "bogus connector number in CCI: %u\n",
+ num);
+ return;
+ }
+ con = &ucsi->connector[num - 1];
+
if (!test_and_set_bit(EVENT_PENDING, &ucsi->flags))
schedule_work(&con->work);
}
--
2.34.1
next reply other threads:[~2026-05-08 9:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 9:20 Hongbo Li [this message]
2026-05-08 11:03 ` [PATCH 6.6 & 5.10] usb: typec: ucsi: validate connector number in ucsi_connector_change Greg KH
2026-05-08 12:59 ` Hongbo Li
2026-05-08 13:04 ` Greg KH
2026-05-09 3:32 ` Hongbo Li
2026-05-09 3:52 ` Greg KH
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=20260508092026.1364820-1-lihongbo22@huawei.com \
--to=lihongbo22@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=kyungtae.kim@dartmouth.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nathan.c.rebello@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox