Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Yaxiong Tian and committed by
Chanwoo Choi
e66523c7 b85ea95d

+1 -2
+1 -2
drivers/extcon/extcon.c
··· 1280 1280 1281 1281 edev->id = ret; 1282 1282 1283 - dev_set_name(&edev->dev, "extcon%d", edev->id); 1284 - 1285 1283 ret = extcon_alloc_cables(edev); 1286 1284 if (ret < 0) 1287 1285 goto err_alloc_cables; ··· 1308 1310 RAW_INIT_NOTIFIER_HEAD(&edev->nh_all); 1309 1311 1310 1312 dev_set_drvdata(&edev->dev, edev); 1313 + dev_set_name(&edev->dev, "extcon%d", edev->id); 1311 1314 edev->state = 0; 1312 1315 1313 1316 ret = device_register(&edev->dev);