Linux USB
 help / color / mirror / Atom feed
* [PATCH] fix: drivers/usb/typec/altmodes: dp_altmode_probe: missing typec_altmode_put_plug on error path
@ 2026-06-27  3:41 WenTao Liang
  2026-07-13  9:00 ` Heikki Krogerus
  0 siblings, 1 reply; 2+ messages in thread
From: WenTao Liang @ 2026-06-27  3:41 UTC (permalink / raw)
  To: heikki.krogerus, gregkh; +Cc: linux-usb, linux-kernel, WenTao Liang, stable

In dp_altmode_probe(), typec_altmode_get_plug() acquires a reference on
plug. When the data role check fails (TYPEC_HOST check), the function
returns -EPROTO without calling typec_altmode_put_plug(plug), leaking the
plug reference. Other error paths (ENODEV, ENOMEM) correctly release the
reference.

Add typec_altmode_put_plug(plug) before returning on the EPROTO error
path to fix the leak.

Cc: stable@vger.kernel.org
Fixes: 41294342fad7 ("usb: typec: altmodes/displayport: do not enter mode if port is the UFP")
Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
---
 drivers/usb/typec/altmodes/displayport.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
index 263a89c5f324..06fe04e9e9b5 100644
--- a/drivers/usb/typec/altmodes/displayport.c
+++ b/drivers/usb/typec/altmodes/displayport.c
@@ -766,8 +766,10 @@ int dp_altmode_probe(struct typec_altmode *alt)
 	struct dp_altmode *dp;
 
 	/* Port can only be DFP_U. */
-	if (typec_altmode_get_data_role(alt) != TYPEC_HOST)
+	if (typec_altmode_get_data_role(alt) != TYPEC_HOST) {
+		typec_altmode_put_plug(plug);
 		return -EPROTO;
+	}
 
 	/* Make sure we have compatible pin configurations */
 	if (!(DP_CAP_PIN_ASSIGN_DFP_D(port->vdo) &
-- 
2.39.5 (Apple Git-154)


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

end of thread, other threads:[~2026-07-13  9:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-27  3:41 [PATCH] fix: drivers/usb/typec/altmodes: dp_altmode_probe: missing typec_altmode_put_plug on error path WenTao Liang
2026-07-13  9:00 ` Heikki Krogerus

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