usb: typec: altmodes/displayport: Drop the device reference in dp_altmode_probe()

In error paths, call typec_altmode_put_plug() to drop the device reference
obtained by typec_altmode_get_plug().

Fixes: 71ba4fe566 ("usb: typec: altmodes/displayport: add SOP' support")
Cc: stable <stable@kernel.org>
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://patch.msgid.link/20251206070445.190770-1-lihaoxiang@isrc.iscas.ac.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Haoxiang Li 2025-12-06 15:04:45 +08:00 committed by Greg Kroah-Hartman
parent 41ca62e3e2
commit 128bb7fab3

View File

@ -766,12 +766,16 @@ int dp_altmode_probe(struct typec_altmode *alt)
if (!(DP_CAP_PIN_ASSIGN_DFP_D(port->vdo) &
DP_CAP_PIN_ASSIGN_UFP_D(alt->vdo)) &&
!(DP_CAP_PIN_ASSIGN_UFP_D(port->vdo) &
DP_CAP_PIN_ASSIGN_DFP_D(alt->vdo)))
DP_CAP_PIN_ASSIGN_DFP_D(alt->vdo))) {
typec_altmode_put_plug(plug);
return -ENODEV;
}
dp = devm_kzalloc(&alt->dev, sizeof(*dp), GFP_KERNEL);
if (!dp)
if (!dp) {
typec_altmode_put_plug(plug);
return -ENOMEM;
}
INIT_WORK(&dp->work, dp_altmode_work);
mutex_init(&dp->lock);