From: Benson Leung <bleung@google.com>
To: Jameson Thies <jthies@google.com>
Cc: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org,
jonathanh@nvidia.com, abhishekpandit@chromium.org,
andersson@kernel.org, dmitry.baryshkov@linaro.org,
fabrice.gasnier@foss.st.com, gregkh@linuxfoundation.org,
hdegoede@redhat.com, neil.armstrong@linaro.org,
rajaram.regupathy@intel.com, saranya.gopal@intel.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] usb: typec: ucsi: Only set number of plug altmodes after registration
Date: Tue, 25 Jun 2024 00:50:19 +0000 [thread overview]
Message-ID: <ZnoUS1kOL3aYar-Q@google.com> (raw)
In-Reply-To: <20240625004607.3223757-1-jthies@google.com>
[-- Attachment #1: Type: text/plain, Size: 1614 bytes --]
Hi Jameson,
On Tue, Jun 25, 2024 at 12:46:07AM +0000, Jameson Thies wrote:
> Move the setting of the plug's number of alternate modes into the
> same condition as the plug's registration to prevent dereferencing the
> connector's plug pointer while it is null.
>
> Fixes: c313a44ac9cd ("usb: typec: ucsi: Always set number of alternate modes")
> Suggested-by: Jon Hunter <jonathanh@nvidia.com>
> Signed-off-by: Jameson Thies <jthies@google.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
Thanks,
Benson
> ---
> drivers/usb/typec/ucsi/ucsi.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 76c48d873b2a..77e46bf4a098 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -1180,13 +1180,13 @@ static int ucsi_check_cable(struct ucsi_connector *con)
> ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_SOP_P);
> if (ret < 0)
> return ret;
> - }
>
> - if (con->plug_altmode[0]) {
> - num_plug_am = ucsi_get_num_altmode(con->plug_altmode);
> - typec_plug_set_num_altmodes(con->plug, num_plug_am);
> - } else {
> - typec_plug_set_num_altmodes(con->plug, 0);
> + if (con->plug_altmode[0]) {
> + num_plug_am = ucsi_get_num_altmode(con->plug_altmode);
> + typec_plug_set_num_altmodes(con->plug, num_plug_am);
> + } else {
> + typec_plug_set_num_altmodes(con->plug, 0);
> + }
> }
>
> return 0;
>
> base-commit: 819984a0dd3606b7c46fe156cd56a0dc0d604788
> --
> 2.45.2.741.gdbec12cfda-goog
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2024-06-25 0:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 0:46 [PATCH v1] usb: typec: ucsi: Only set number of plug altmodes after registration Jameson Thies
2024-06-25 0:50 ` Benson Leung [this message]
2024-06-25 10:55 ` Jon Hunter
2024-06-25 14:32 ` 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=ZnoUS1kOL3aYar-Q@google.com \
--to=bleung@google.com \
--cc=abhishekpandit@chromium.org \
--cc=andersson@kernel.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=fabrice.gasnier@foss.st.com \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=jonathanh@nvidia.com \
--cc=jthies@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rajaram.regupathy@intel.com \
--cc=saranya.gopal@intel.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