summaryrefslogtreecommitdiffstats
path: root/drivers/extcon
diff options
context:
space:
mode:
authorYaxiong Tian <tianyaxiong@kylinos.cn>2023-11-24 09:49:13 +0800
committerChanwoo Choi <cw00.choi@samsung.com>2023-12-04 21:47:19 +0900
commite66523c72c9aae0ff0dae6859eb77b04de1e8e5f (patch)
treed8cf42b3481a454b7daaa9f8c409e6a766b154e6 /drivers/extcon
parentb85ea95d086471afb4ad062012a4d73cd328fa86 (diff)
downloadlinux-e66523c72c9aae0ff0dae6859eb77b04de1e8e5f.tar.gz
linux-e66523c72c9aae0ff0dae6859eb77b04de1e8e5f.tar.bz2
linux-e66523c72c9aae0ff0dae6859eb77b04de1e8e5f.zip
extcon: fix possible name leak in extcon_dev_register()
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. Link: https://lore.kernel.org/lkml/TYZPR01MB4784ADCD3E951E0863F3DB72D5B8A@TYZPR01MB4784.apcprd01.prod.exchangelabs.com/ Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon')
-rw-r--r--drivers/extcon/extcon.c3
1 files changed, 1 insertions, 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);