Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 71ba4fe56656 ("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>

authored by

Haoxiang Li and committed by
Greg Kroah-Hartman
128bb7fa 41ca62e3

+6 -2
+6 -2
drivers/usb/typec/altmodes/displayport.c
··· 766 766 if (!(DP_CAP_PIN_ASSIGN_DFP_D(port->vdo) & 767 767 DP_CAP_PIN_ASSIGN_UFP_D(alt->vdo)) && 768 768 !(DP_CAP_PIN_ASSIGN_UFP_D(port->vdo) & 769 - DP_CAP_PIN_ASSIGN_DFP_D(alt->vdo))) 769 + DP_CAP_PIN_ASSIGN_DFP_D(alt->vdo))) { 770 + typec_altmode_put_plug(plug); 770 771 return -ENODEV; 772 + } 771 773 772 774 dp = devm_kzalloc(&alt->dev, sizeof(*dp), GFP_KERNEL); 773 - if (!dp) 775 + if (!dp) { 776 + typec_altmode_put_plug(plug); 774 777 return -ENOMEM; 778 + } 775 779 776 780 INIT_WORK(&dp->work, dp_altmode_work); 777 781 mutex_init(&dp->lock);