mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chanwoo Choi <cwchoi00@gmail.com>
To: Miles Krause <mileskrause5200@gmail.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>, Xu Yang <xu.yang_2@nxp.com>,
	Frank Li <Frank.Li@nxp.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] extcon: ptn5150: fix fwnode reference leak in ptn5150_i2c_probe()
Date: Sat, 28 Nov 2026 08:14:30 +0900	[thread overview]
Message-ID: <fa303423-0dc6-4075-9c0a-d32dbc6d8631@gmail.com> (raw)
In-Reply-To: <20260906-extcon-ptn5150-fwnode-leak-v1-1-42c2ff731138@gmail.com>

On 9/7/2026 4:49 AM, Miles Krause wrote:
> ptn5150_i2c_probe() looks up the "connector" child node with
> device_get_named_child_node(), but never releases the reference that
> the lookup returns.
> 
> fwnode_typec_switch_get() and fwnode_usb_role_switch_get() each take
> their own reference on the switch they hand back, so the caller still
> owns the fwnode reference.  Nothing in the driver drops it: the devm
> cleanup handler ptn5150_work_sync_and_put() releases info->role_sw and
> info->orient_sw only.  The node is therefore leaked on both error
> returns that follow the lookup, and on a fully successful probe.
> 
> Declare 'connector' with __free(fwnode_handle) so that the reference is
> released on every path out of the function.
> 
> Fixes: 842546c56345 ("extcon: ptn5150: Add Type-C orientation switch support")
> Signed-off-by: Miles Krause <mileskrause5200@gmail.com>
> ---
>  drivers/extcon/extcon-ptn5150.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c
> index eca1b140aeb0..ede38eec2466 100644
> --- a/drivers/extcon/extcon-ptn5150.c
> +++ b/drivers/extcon/extcon-ptn5150.c
> @@ -256,7 +256,6 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c)
>  {
>  	struct device *dev = &i2c->dev;
>  	struct device_node *np = i2c->dev.of_node;
> -	struct fwnode_handle *connector;
>  	struct ptn5150_info *info;
>  	int ret;
>  
> @@ -343,7 +342,8 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c)
>  	if (ret)
>  		return -EINVAL;
>  
> -	connector = device_get_named_child_node(dev, "connector");
> +	struct fwnode_handle *connector __free(fwnode_handle) =
> +		device_get_named_child_node(dev, "connector");
>  	if (connector) {
>  		info->orient_sw = fwnode_typec_switch_get(connector);
>  		if (IS_ERR(info->orient_sw))
> 
> ---
> base-commit: 88405f0ad1d5c680afe3ea0ce9345fa9e1deaac8
> change-id: 20260906-extcon-ptn5150-fwnode-leak-81c395149a9d
> 
> Best regards,

Applied it. Thanks.

-- 
Best Regards,
Chanwoo Choi
Principal Engineer, Samsung Electronics

      parent reply	other threads:[~2026-11-27 23:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06 19:49 Miles Krause
2026-09-07  2:58 ` Xu Yang
2026-11-27 23:14 ` Chanwoo Choi [this message]

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=fa303423-0dc6-4075-9c0a-d32dbc6d8631@gmail.com \
    --to=cwchoi00@gmail.com \
    --cc=Frank.Li@nxp.com \
    --cc=chanwoo@kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mileskrause5200@gmail.com \
    --cc=myungjoo.ham@samsung.com \
    --cc=xu.yang_2@nxp.com \
    /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

all inboxes | Powered by JetHome®