Commit 128bb7fa authored by Haoxiang Li's avatar Haoxiang Li Committed by Greg Kroah-Hartman
Browse files

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: 71ba4fe5 ("usb: typec: altmodes/displayport: add SOP' support")
Cc: stable <stable@kernel.org>
Signed-off-by: default avatarHaoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://patch.msgid.link/20251206070445.190770-1-lihaoxiang@isrc.iscas.ac.cn


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 41ca62e3
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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);