From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Andrei Kuchynski <akuchynski@chromium.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Benson Leung <bleung@chromium.org>,
Jameson Thies <jthies@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH 2/2] usb: typec: class: Invalidate USB device pointers on partner unregistration
Date: Mon, 24 Mar 2025 11:43:46 +0200 [thread overview]
Message-ID: <Z-EpUlA9VOBO9yd4@kuha.fi.intel.com> (raw)
In-Reply-To: <20250321143728.4092417-3-akuchynski@chromium.org>
On Fri, Mar 21, 2025 at 02:37:27PM +0000, Andrei Kuchynski wrote:
> To avoid using invalid USB device pointers after a Type-C partner
> disconnects, this patch clears the pointers upon partner unregistration.
> This ensures a clean state for future connections.
>
> Cc: stable@vger.kernel.org
> Fixes: 59de2a56d127 ("usb: typec: Link enumerated USB devices with Type-C partner")
> Signed-off-by: Andrei Kuchynski <akuchynski@chromium.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/class.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index eadb150223f8..3df3e3736916 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -1086,10 +1086,14 @@ void typec_unregister_partner(struct typec_partner *partner)
> port = to_typec_port(partner->dev.parent);
>
> mutex_lock(&port->partner_link_lock);
> - if (port->usb2_dev)
> + if (port->usb2_dev) {
> typec_partner_unlink_device(partner, port->usb2_dev);
> - if (port->usb3_dev)
> + port->usb2_dev = NULL;
> + }
> + if (port->usb3_dev) {
> typec_partner_unlink_device(partner, port->usb3_dev);
> + port->usb3_dev = NULL;
> + }
>
> device_unregister(&partner->dev);
> mutex_unlock(&port->partner_link_lock);
> --
> 2.49.0.395.g12beb8f557-goog
--
heikki
prev parent reply other threads:[~2025-03-24 9:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 14:37 [PATCH 0/2] Fix invalid pointer access Andrei Kuchynski
2025-03-21 14:37 ` [PATCH 1/2] usb: typec: class: Fix NULL " Andrei Kuchynski
2025-03-21 23:16 ` Benson Leung
2025-03-24 9:42 ` Heikki Krogerus
2025-03-21 14:37 ` [PATCH 2/2] usb: typec: class: Invalidate USB device pointers on partner unregistration Andrei Kuchynski
2025-03-21 23:19 ` Benson Leung
2025-03-24 9:43 ` Heikki Krogerus [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=Z-EpUlA9VOBO9yd4@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=akuchynski@chromium.org \
--cc=bleung@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=jthies@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@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.