mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: typec: Fix PD object leak in select_usb_power_delivery_store()
@ 2026-09-16 17:01 Wentao Liang
  2026-09-18  9:53 ` Heikki Krogerus
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-16 17:01 UTC (permalink / raw)
  To: gregkh; +Cc: heikki.krogerus, linux-kernel, linux-usb, Wentao Liang, stable

select_usb_power_delivery_store() looks up the requested USB Power
Delivery object with usb_power_delivery_find(), which returns the
object with a reference taken by class_find_device_by_name(). The
reference is never dropped, neither when port->ops->pd_set() fails nor
when it succeeds, leaking a reference to the USB PD object on every
sysfs store.

Drop the reference with put_device() once the pd_set() callback has
returned and the object is no longer needed.

Fixes: a7cff92f0635 ("usb: typec: USB Power Delivery helpers for ports and partners")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/usb/typec/class.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 0977581ad1b6..0595e8cb83aa 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -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;
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-18  9:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 17:01 [PATCH] usb: typec: Fix PD object leak in select_usb_power_delivery_store() Wentao Liang
2026-09-18  9:53 ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®