Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wentao Liang" <vulab@iscas.ac.cn>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: typec: rt1719: unregister the port on probe failure
Date: Wed, 04 Nov 2026 02:30:49 +0000	[thread overview]
Message-ID: <sashiko-outbox-196476@kernel.org> (raw)
In-Reply-To: <20261104021514.1468596-1-vulab@iscas.ac.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usb: typec: rt1719: missing typec_unregister_partner() in rt1719_probe()
--

commit aeb856a2c764adde23b2f8df2e3537e93dbc9fee
Author: Wentao Liang <vulab@iscas.ac.cn>

usb: typec: rt1719: unregister the port on probe failure

This commit adds an err_unregister_port error path label in rt1719_probe()
to call typec_unregister_port(data->port) if rt1719_init_attach_state() or
rt1719_irq_init() fails after the Type-C port has been registered.

> diff --git a/drivers/usb/typec/rt1719.c b/drivers/usb/typec/rt1719.c
> index 0b0c23a0b014b..61fa865637c70 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);

[Severity: High]
Does err_unregister_port in drivers/usb/typec/rt1719.c:rt1719_probe() also
need to call typec_unregister_partner(data->partner) before
typec_unregister_port(data->port)?

Before rt1719_irq_init(data) is called, rt1719_init_attach_state(data) runs:

drivers/usb/typec/rt1719.c:rt1719_init_attach_state() {
	...
	if (conn_info & RT1719_ATTACHDEV_MASK)
		rt1719_attach(data);

	if (conn_info & RT1719_PE_EXP_CONTRACT) {
		rt1719_update_source_pdos(data);
		rt1719_update_pwr_opmode(data);
	}
	...
}

If a partner is already attached at probe time, rt1719_attach() or
rt1719_update_pwr_opmode() calls rt1719_register_partner(data), which
registers data->partner as a child device of data->port via
typec_register_partner(data->port, &data->partner_desc) with
partner->identity pointing to &data->partner_ident.

If rt1719_irq_init(data) then fails and jumps to err_unregister_port,
typec_unregister_port(data->port) is called while data->partner is still
registered. Because typec_unregister_port() only calls
device_unregister(&port->dev) and does not unregister child partner devices,
data->partner remains registered in sysfs holding its parent reference on
data->port->dev (leaking both data->partner and data->port), and its
partner->identity pointer dangles into the devm-allocated struct rt1719_data
once rt1719_probe() returns an error.

Since typec_unregister_partner() safely ignores NULL or ERR_PTR pointers,
should typec_unregister_partner(data->partner) be called right before
typec_unregister_port(data->port), matching rt1719_remove()?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261104021514.1468596-1-vulab@iscas.ac.cn?part=1

  reply	other threads:[~2026-11-04  2:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  2:15 [PATCH] usb: typec: rt1719: unregister the port on probe failure Wentao Liang
2026-11-04  2:30 ` sashiko-bot [this message]
2026-11-04  7:12 ` Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-196476@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vulab@iscas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox