* [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
* Re: [PATCH] fix: drivers/usb/typec/altmodes: dp_altmode_probe: missing typec_altmode_put_plug on error path
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
0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2026-07-13 9:00 UTC (permalink / raw)
To: WenTao Liang; +Cc: gregkh, linux-usb, linux-kernel, stable
Hi,
I hate complain about trivial things, but the subject line has a bit
too much information. You have to improve it.
Please take a look at how the previous commits were written. My
suggestion is that you change it to, for example,
"usb: typec: displayport: Fix a plug altmode leak"
or
"usb: typec: displayport: Add missing typec_altmode_put_plug call"
Thanks,
On Sat, Jun 27, 2026 at 11:41:43AM +0800, WenTao Liang kirjoitti:
> 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>
--
heikki
^ permalink raw reply [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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.