tcpm_register_sink_caps() registers a new "sink-capabilities" device under the partner USB PD object every time a Sink_Capabilities message is received, but the previously registered one is only removed on detach. sink_cap_done is cleared on Hard Reset, so the sink capabilities are queried and registered again on the same partner: registering a second device with the same name under the same parent fails, and the stale capabilities stay exposed in sysfs. Unregister the previous capabilities before registering the new ones. Cc: stable@vger.kernel.org Fixes: 8203d26905ee ("usb: typec: tcpm: Register USB Power Delivery Capabilities") Assisted-by: LLM Signed-off-by: Neil Armstrong --- drivers/usb/typec/tcpm/tcpm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 1d007e59a2bf..c5a4c0b6da16 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -3563,6 +3563,8 @@ static int tcpm_register_sink_caps(struct tcpm_port *port) if (IS_ERR(cap)) return PTR_ERR(cap); + if (port->partner_sink_caps) + usb_power_delivery_unregister_capabilities(port->partner_sink_caps); port->partner_sink_caps = cap; return 0; -- 2.34.1