Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: typec: thunderbolt: release a non-Thunderbolt cable plug
@ 2026-11-04  2:15 Wentao Liang
  2026-11-04  2:26 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-11-04  2:15 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman; +Cc: linux-usb

tbt_ready() takes a reference on each cable plug with
typec_altmode_get_plug() and keeps it in tbt->plug[] for the lifetime of
the alternate mode.  When a plug reports an SVID other than Thunderbolt,
the loop breaks without storing the plug, so the reference taken for it
is never dropped.

Put that plug before leaving the loop on the SVID mismatch path.

Fixes: 100e25738659 ("usb: typec: Add driver for Thunderbolt 3 Alternate Mode")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/usb/typec/altmodes/thunderbolt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/altmodes/thunderbolt.c b/drivers/usb/typec/altmodes/thunderbolt.c
index 2e1b1a1da7d9..fad48aae6751 100644
--- a/drivers/usb/typec/altmodes/thunderbolt.c
+++ b/drivers/usb/typec/altmodes/thunderbolt.c
@@ -340,8 +340,10 @@ static bool tbt_ready(struct typec_altmode *alt)
 		if (!plug)
 			continue;
 
-		if (plug->svid != USB_TYPEC_TBT_SID)
+		if (plug->svid != USB_TYPEC_TBT_SID) {
+			typec_altmode_put_plug(plug);
 			break;
+		}
 
 		plug->desc = "Thunderbolt3";
 		plug->cable_ops = &tbt_cable_ops;
-- 
2.34.1


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

* Re: [PATCH] usb: typec: thunderbolt: release a non-Thunderbolt cable plug
  2026-11-04  2:15 [PATCH] usb: typec: thunderbolt: release a non-Thunderbolt cable plug Wentao Liang
@ 2026-11-04  2:26 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-04  2:26 UTC (permalink / raw)
  To: Wentao Liang; +Cc: linux-usb

> tbt_ready() takes a reference on each cable plug with
> typec_altmode_get_plug() and keeps it in tbt->plug[] for the lifetime of
> the alternate mode.  When a plug reports an SVID other than Thunderbolt,
> the loop breaks without storing the plug, so the reference taken for it
> is never dropped.
> 
> Put that plug before leaving the loop on the SVID mismatch path.
> 
> Fixes: 100e25738659 ("usb: typec: Add driver for Thunderbolt 3 Alternate Mode")
> Cc: stable@vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261104021516.1468625-1-vulab@iscas.ac.cn?part=1


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

end of thread, other threads:[~2026-11-04  2:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  2:15 [PATCH] usb: typec: thunderbolt: release a non-Thunderbolt cable plug Wentao Liang
2026-11-04  2:26 ` sashiko-bot

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