[PATCH] fix: drivers/usb/typec/altmodes: dp_altmode_probe: missing typec_altmode_put_plug on error path
From: WenTao Liang
Date: Fri Jun 26 2026 - 23:42:09 EST
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@xxxxxxxxxxxxxxx
Fixes: 41294342fad7 ("usb: typec: altmodes/displayport: do not enter mode if port is the UFP")
Signed-off-by: WenTao Liang <vulab@xxxxxxxxxxx>
---
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)