From: sashiko-bot@kernel.org
To: "Kyle Tso" <kyletso@google.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v1] usb: typec: tcpm: Clear pps_data in tcpm_reset_port()
Date: Thu, 03 Dec 2026 14:25:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-247959@kernel.org> (raw)
In-Reply-To: <20261203140023.2275666-1-kyletso@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] usb: typec: tcpm: unsynchronized early pps_data memset in
tcpm_reset_port()
--
commit 07c97444e7154a6e5c8ed5b6cc157c2333dc910a
Author: Kyle Tso <kyletso@google.com>
usb: typec: tcpm: Clear pps_data in tcpm_reset_port()
This commit clears the entire port->pps_data structure in tcpm_reset_port()
instead of only clearing port->pps_data.supported.
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index ca38e05f831a7..72b08d69ff808 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -5178,7 +5178,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
> tcpm_typec_disconnect(port);
> port->attached = false;
> port->pd_capable = false;
> - port->pps_data.supported = false;
> + memset(&port->pps_data, 0, sizeof(port->pps_data));
> tcpm_set_partner_usb_comm_capable(port, false);
>
> /*
[Severity: Low]
Can clearing port->pps_data here cause tcpm_psy_get_online() to transiently
report TCPM_PSY_FIXED_ONLINE during a PPS detach or reset?
tcpm_reset_port() clears port->pps_data.active before sleeping TCPC bus
calls (set_pd_rx() and set_vbus() in tcpm_init_vbus()) and before
tcpm_init_vbus() sets port->vbus_charge to false. Because
tcpm_psy_get_online() does not take port->lock, a concurrent power_supply
reader can observe the intermediate state:
CPU0 CPU1
tcpm_reset_port()
memset(&port->pps_data, 0, ...)
set_pd_rx(..., false)
tcpm_psy_get_online()
port->vbus_charge == true
port->pps_data.active == false
<-- returns TCPM_PSY_FIXED_ONLINE
tcpm_init_vbus()
port->vbus_charge = false
Separately, struct pd_pps_data places min_volt, max_volt, and max_curr
before active, so memset() zeroes those fields before clearing active.
Concurrent lockless readers such as tcpm_psy_get_voltage_max() can race
with this memset() and observe active as true with zeroed or torn bounds.
Clearing port->pps_data after tcpm_init_vbus() would avoid the
TCPM_PSY_FIXED_ONLINE window once port->vbus_charge is false.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203140023.2275666-1-kyletso@google.com?part=1
prev parent reply other threads:[~2026-12-03 14:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 14:00 [PATCH v1] usb: typec: tcpm: Clear pps_data in tcpm_reset_port() Kyle Tso
2026-12-03 14:25 ` sashiko-bot [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=sashiko-outbox-247959@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kyletso@google.com \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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