The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] usb: typec: ucsi: Correct teardown ordering in ucsi_init() error path
@ 2026-07-17  9:50 Andrei Kuchynski
  2026-07-17 10:16 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Andrei Kuchynski @ 2026-07-17  9:50 UTC (permalink / raw)
  To: Heikki Krogerus, Jameson Thies, Benson Leung, linux-usb,
	linux-kernel
  Cc: Greg Kroah-Hartman, Pooja Katiyar, Abhishek Pandit-Subedi,
	Johan Hovold, Hsin-Te Yuan, Myrrh Periwinkle, Jack Pham,
	Borah, Chaitanya Kumar, Sergey Senozhatsky, Andrei Kuchynski,
	stable

The commit 7aa7d4bf9d3f ("usb: typec: ucsi: Fix race condition and
ordering in port unregistration") consolidated port teardown into the
ucsi_unregister_port() helper. However, it introduced an ordering problem
in the ucsi_init() error path.

Fix this by ensuring ucsi_unregister_port() is called before we unregister
their corresponding lockdep keys.

Cc: stable@vger.kernel.org
Fixes: 7aa7d4bf9d3f ("usb: typec: ucsi: Fix race condition and ordering in port unregistration")
Link: https://lore.kernel.org/all/22064276-6c56-411a-9f20-6917ceeb865f@intel.com/
Signed-off-by: Andrei Kuchynski <akuchynski@chromium.org>
---
 drivers/usb/typec/ucsi/ucsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 1ae4224d2dfc3..49f1c53721bbd 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -2142,11 +2142,11 @@ static int ucsi_init(struct ucsi *ucsi)
 	return 0;
 
 err_unregister:
+	for (con = connector; con->port; con++)
+		ucsi_unregister_port(con);
 	for (i = 0; i < ucsi->cap.num_connectors; i++)
 		lockdep_unregister_key(&connector[i].lock_key);
 
-	for (con = connector; con->port; con++)
-		ucsi_unregister_port(con);
 	kfree(connector);
 err_reset:
 	memset(&ucsi->cap, 0, sizeof(ucsi->cap));
-- 
2.55.0.229.g6434b31f56-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: typec: ucsi: Correct teardown ordering in ucsi_init() error path
  2026-07-17  9:50 [PATCH] usb: typec: ucsi: Correct teardown ordering in ucsi_init() error path Andrei Kuchynski
@ 2026-07-17 10:16 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2026-07-17 10:16 UTC (permalink / raw)
  To: Andrei Kuchynski
  Cc: Heikki Krogerus, Jameson Thies, Benson Leung, linux-usb,
	linux-kernel, Pooja Katiyar, Abhishek Pandit-Subedi, Johan Hovold,
	Hsin-Te Yuan, Myrrh Periwinkle, Jack Pham, Borah, Chaitanya Kumar,
	Sergey Senozhatsky, stable

On Fri, Jul 17, 2026 at 09:50:06AM +0000, Andrei Kuchynski wrote:
> The commit 7aa7d4bf9d3f ("usb: typec: ucsi: Fix race condition and
> ordering in port unregistration") consolidated port teardown into the
> ucsi_unregister_port() helper. However, it introduced an ordering problem
> in the ucsi_init() error path.
> 
> Fix this by ensuring ucsi_unregister_port() is called before we unregister
> their corresponding lockdep keys.
> 
> Cc: stable@vger.kernel.org
> Fixes: 7aa7d4bf9d3f ("usb: typec: ucsi: Fix race condition and ordering in port unregistration")
> Link: https://lore.kernel.org/all/22064276-6c56-411a-9f20-6917ceeb865f@intel.com/
> Signed-off-by: Andrei Kuchynski <akuchynski@chromium.org>
> ---
>  drivers/usb/typec/ucsi/ucsi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

You forgot a reported-by: tag :(


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-17 10:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-17  9:50 [PATCH] usb: typec: ucsi: Correct teardown ordering in ucsi_init() error path Andrei Kuchynski
2026-07-17 10:16 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox