]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
usb: typec: altmodes/displayport: Drop the device reference in dp_altmode_probe()
authorHaoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Sat, 6 Dec 2025 07:04:45 +0000 (15:04 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Dec 2025 13:53:16 +0000 (14:53 +0100)
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>
drivers/usb/typec/altmodes/displayport.c

index 8d111ad3b71b8066d07c35a3bf24b481c888d633..d96ab106a980bd44590f8dbb5d7596d0e4e2c235 100644 (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);