From: Greg KH <gregkh@linuxfoundation.org>
To: DongliLiu <dongli.liu@outlook.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: typec: ucsi: Fix off-by-one in connector validation
Date: Tue, 30 Jun 2026 16:17:42 +0200 [thread overview]
Message-ID: <2026063017-mayflower-shuffle-9051@gregkh> (raw)
In-Reply-To: <KUZPR04MB89683432655A607BE9A4838F85F72@KUZPR04MB8968.apcprd04.prod.outlook.com>
On Tue, Jun 30, 2026 at 07:30:31PM +0800, DongliLiu wrote:
> From: DongliLiu <dongli.liu@outlook.com>
> Date: Mon, 30 Jun 2026 19:30:00 +0800
> Subject: [PATCH] usb: typec: ucsi: Fix off-by-one in connector validation
>
> UCSI_CCI_CONNECTOR() returns a 1-based connector index, while
> num_connectors represents the total count of connectors. Using '<='
> allows num_connectors itself as a valid index, which is off-by-one
> since valid indices are 0 to num_connectors-1.
>
> Change the comparison from '<=' to '<' to correctly reject the
> out-of-bounds case.
>
> Signed-off-by: DongliLiu <dongli.liu@outlook.com>
> ---
> drivers/usb/typec/ucsi/ucsi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index xxxxxxx..yyyyyyy 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -xxx,yyy @@@ static void ucsi_notify_common(struct ucsi *ucsi, u32 cci)
> ...
>
> - if (UCSI_CCI_CONNECTOR(cci) <= ucsi->cap.num_connectors)
> + if (UCSI_CCI_CONNECTOR(cci) < ucsi->cap.num_connectors)
> ...
Please actually create patches that can be applied and not use LLM tools
without documenting it properly.
thanks,
greg k-h
prev parent reply other threads:[~2026-06-30 14:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 11:30 [PATCH] usb: typec: ucsi: Fix off-by-one in connector validation DongliLiu
2026-06-30 14:17 ` Greg KH [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=2026063017-mayflower-shuffle-9051@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=dongli.liu@outlook.com \
--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.