public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Chanwoo Choi" <cw00.choi@samsung.com>
To: "'Yaxiong Tian'" <iambestgod@outlook.com>, <myungjoo.ham@samsung.com>
Cc: <linux-kernel@vger.kernel.org>, <tianyaxiong@kylinos.cn>
Subject: RE: [PATCH] extcon: fix possible name leak in extcon_dev_register()
Date: Mon, 4 Dec 2023 21:22:19 +0900	[thread overview]
Message-ID: <000e01da26ac$86a5e3a0$93f1aae0$@samsung.com> (raw)
In-Reply-To: <TYZPR01MB4784ADCD3E951E0863F3DB72D5B8A@TYZPR01MB4784.apcprd01.prod.exchangelabs.com>



> -----Original Message-----
> From: Yaxiong Tian <iambestgod@outlook.com>
> Sent: Friday, November 24, 2023 10:49 AM
> To: myungjoo.ham@samsung.com; cw00.choi@samsung.com
> Cc: linux-kernel@vger.kernel.org; tianyaxiong@kylinos.cn
> Subject: [PATCH] extcon: fix possible name leak in extcon_dev_register()
> 
> From: Yaxiong Tian <tianyaxiong@kylinos.cn>
> 
> In the error path after calling dev_set_name(), the device name is leaked.
> To fix this,Moving dev_set_name() after the error path and before
> device_register.
> 
> Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
> ---
>  drivers/extcon/extcon.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index
> 6f7a60d2ed91..e7f55c021e56 100644
> --- a/drivers/extcon/extcon.c
> +++ b/drivers/extcon/extcon.c
> @@ -1280,8 +1280,6 @@ int extcon_dev_register(struct extcon_dev *edev)
> 
>  	edev->id = ret;
> 
> -	dev_set_name(&edev->dev, "extcon%d", edev->id);
> -
>  	ret = extcon_alloc_cables(edev);
>  	if (ret < 0)
>  		goto err_alloc_cables;
> @@ -1310,6 +1308,7 @@ int extcon_dev_register(struct extcon_dev *edev)
>  	RAW_INIT_NOTIFIER_HEAD(&edev->nh_all);
> 
>  	dev_set_drvdata(&edev->dev, edev);
> +	dev_set_name(&edev->dev, "extcon%d", edev->id);
>  	edev->state = 0;
> 
>  	ret = device_register(&edev->dev);
> --
> 2.25.1


Applied it. Thanks.

Best Regards,
Chanwoo Choi


      reply	other threads:[~2023-12-04 12:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20231124014941epcas1p2f6a6751a6a0aac64ffee54ddc74da0bb@epcas1p2.samsung.com>
2023-11-24  1:49 ` [PATCH] extcon: fix possible name leak in extcon_dev_register() Yaxiong Tian
2023-12-04 12:22   ` 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='000e01da26ac$86a5e3a0$93f1aae0$@samsung.com' \
    --to=cw00.choi@samsung.com \
    --cc=iambestgod@outlook.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=tianyaxiong@kylinos.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