]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
usb: typec: class: drop PD lookup reference
authorShuangpeng Bai <shuangpeng.kernel@gmail.com>
Thu, 2 Jul 2026 19:13:29 +0000 (15:13 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Jul 2026 11:55:10 +0000 (13:55 +0200)
usb_power_delivery_find() wraps class_find_device_by_name(). That helper
returns a device reference that must be released by the caller.

select_usb_power_delivery_store() only needs this reference while calling
the pd_set callback. Drop it once the callback returns. Otherwise the sysfs
write can pin the selected USB Power Delivery object and prevent it from
being released on unregister.

Fixes: a7cff92f0635 ("usb: typec: USB Power Delivery helpers for ports and partners")
Cc: stable <stable@kernel.org>
Signed-off-by: Shuangpeng Bai <shuangpeng.kernel@gmail.com>
Link: https://patch.msgid.link/20260702191329.2648043-1-shuangpeng.kernel@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/class.c

index 0977581ad1b6e971764286762d2ea620deabe13d..0595e8cb83aa6765429a9255d42b1fa4214ba925 100644 (file)
@@ -1619,6 +1619,7 @@ static ssize_t select_usb_power_delivery_store(struct device *dev,
                return -EINVAL;
 
        ret = port->ops->pd_set(port, pd);
+       put_device(&pd->dev);
        if (ret)
                return ret;