Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: typec: rt1719: unregister the port on probe failure
@ 2026-11-04  2:15 Wentao Liang
  2026-11-04  2:30 ` sashiko-bot
  2026-11-04  7:12 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-04  2:15 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman; +Cc: linux-usb

typec_register_port() returns a port that has to be released with
typec_unregister_port().  probe() stores it in data->port and
rt1719_remove() unregisters it, but when setting up the attach state or
the interrupt enable fails after registration, the error path only drops
the role switch and the fwnode, leaking the registered Type-C port.

Add a label that unregisters the port before the existing cleanup and
use it on both post-registration error paths.

Fixes: 25d29b980912 ("usb: typec: rt1719: Add support for Richtek RT1719")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/usb/typec/rt1719.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/rt1719.c b/drivers/usb/typec/rt1719.c
index 0b0c23a0b014..61fa865637c7 100644
--- a/drivers/usb/typec/rt1719.c
+++ b/drivers/usb/typec/rt1719.c
@@ -902,13 +902,13 @@ static int rt1719_probe(struct i2c_client *i2c)
 	ret = rt1719_init_attach_state(data);
 	if (ret) {
 		dev_err(&i2c->dev, "Failed to init attach state (%d)\n", ret);
-		goto err_role_put;
+		goto err_unregister_port;
 	}
 
 	ret = rt1719_irq_init(data);
 	if (ret) {
 		dev_err(&i2c->dev, "Failed to init irq\n");
-		goto err_role_put;
+		goto err_unregister_port;
 	}
 
 	fwnode_handle_put(fwnode);
@@ -917,6 +917,8 @@ static int rt1719_probe(struct i2c_client *i2c)
 
 	return 0;
 
+err_unregister_port:
+	typec_unregister_port(data->port);
 err_role_put:
 	usb_role_switch_put(data->role_sw);
 err_fwnode_put:
-- 
2.34.1


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

end of thread, other threads:[~2026-11-04  7:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  2:15 [PATCH] usb: typec: rt1719: unregister the port on probe failure Wentao Liang
2026-11-04  2:30 ` sashiko-bot
2026-11-04  7:12 ` Krzysztof Kozlowski

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