extcon: fix possible name leak in extcon_dev_register()
authorYaxiong Tian <tianyaxiong@kylinos.cn>
Fri, 24 Nov 2023 01:49:13 +0000 (09:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Feb 2024 20:14:31 +0000 (20:14 +0000)
commit8b755fc728cdd7b029f464b51bd6d89e6bcc246d
treecf74eeb9ec86638187f6b5cabc7bd9eb81f51472
parent7c5276c44dd51c8ebb1688603ee089b849723613
extcon: fix possible name leak in extcon_dev_register()

[ Upstream commit e66523c72c9aae0ff0dae6859eb77b04de1e8e5f ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/extcon/extcon.c