* [PATCH] usb: typec: ucsi: Unregister lockdep key only after last lock use
@ 2026-07-20 14:24 Konrad Dybcio
2026-07-21 10:31 ` Heikki Krogerus
0 siblings, 1 reply; 2+ messages in thread
From: Konrad Dybcio @ 2026-07-20 14:24 UTC (permalink / raw)
To: Heikki Krogerus, Greg Kroah-Hartman, Benson Leung,
Andrei Kuchynski
Cc: linux-usb, linux-kernel, Konrad Dybcio, usb4-upstream,
Raghavendra Thoorpu
From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
ucsi_unregister_port() starts off with taking con->lock. Fix the
ucsi_init() teardown path to avoid unregistering the lockdep key
associated with it right before its use.
Fixes: 7aa7d4bf9d3f ("usb: typec: ucsi: Fix race condition and ordering in port unregistration")
Assisted-by: Codex:GPT-5.5
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
---
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Andrei Kuchynski <akuchynski@chromium.org>
To: Benson Leung <bleung@chromium.org>
Cc: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: usb4-upstream@oss.qualcomm.com
Cc: Raghavendra Thoorpu <rthoorpu@qti.qualcomm.com>
---
drivers/usb/typec/ucsi/ucsi.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index d221ca9bc88e..67c75e6bdfae 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -2142,11 +2142,12 @@ 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));
---
base-commit: 0718283ab28bc3907e10b61a6b4be6fefa1cbb2f
change-id: 20260720-topic-ucsi_lockdep-b48ec8de8665
Best regards,
--
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: typec: ucsi: Unregister lockdep key only after last lock use
2026-07-20 14:24 [PATCH] usb: typec: ucsi: Unregister lockdep key only after last lock use Konrad Dybcio
@ 2026-07-21 10:31 ` Heikki Krogerus
0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2026-07-21 10:31 UTC (permalink / raw)
To: Konrad Dybcio
Cc: Greg Kroah-Hartman, Benson Leung, Andrei Kuchynski, linux-usb,
linux-kernel, Konrad Dybcio, usb4-upstream, Raghavendra Thoorpu
On Mon, Jul 20, 2026 at 04:24:27PM +0200, Konrad Dybcio wrote:
> From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>
> ucsi_unregister_port() starts off with taking con->lock. Fix the
> ucsi_init() teardown path to avoid unregistering the lockdep key
> associated with it right before its use.
There's already a fix for this one:
https://lore.kernel.org/linux-usb/20260717104614.325250-1-akuchynski@chromium.org/
> Fixes: 7aa7d4bf9d3f ("usb: typec: ucsi: Fix race condition and ordering in port unregistration")
> Assisted-by: Codex:GPT-5.5
> Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> ---
> To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> To: Andrei Kuchynski <akuchynski@chromium.org>
> To: Benson Leung <bleung@chromium.org>
> Cc: linux-usb@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: usb4-upstream@oss.qualcomm.com
> Cc: Raghavendra Thoorpu <rthoorpu@qti.qualcomm.com>
> ---
> drivers/usb/typec/ucsi/ucsi.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index d221ca9bc88e..67c75e6bdfae 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -2142,11 +2142,12 @@ 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));
Thanks,
--
heikki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-21 10:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-20 14:24 [PATCH] usb: typec: ucsi: Unregister lockdep key only after last lock use Konrad Dybcio
2026-07-21 10:31 ` Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox