* [PATCH] extcon: fix possible name leak in extcon_dev_register()
@ 2023-11-24 1:49 ` Yaxiong Tian
2023-12-04 12:22 ` Chanwoo Choi
0 siblings, 1 reply; 2+ messages in thread
From: Yaxiong Tian @ 2023-11-24 1:49 UTC (permalink / raw)
To: myungjoo.ham, cw00.choi; +Cc: linux-kernel, tianyaxiong
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH] extcon: fix possible name leak in extcon_dev_register()
2023-11-24 1:49 ` [PATCH] extcon: fix possible name leak in extcon_dev_register() Yaxiong Tian
@ 2023-12-04 12:22 ` Chanwoo Choi
0 siblings, 0 replies; 2+ messages in thread
From: Chanwoo Choi @ 2023-12-04 12:22 UTC (permalink / raw)
To: 'Yaxiong Tian', myungjoo.ham; +Cc: linux-kernel, tianyaxiong
> -----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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-04 12:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox