thermal: core: fix some possible name leaks in error paths
authorYang Yingliang <yangyingliang@huawei.com>
Tue, 15 Nov 2022 09:19:45 +0000 (17:19 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:14:02 +0000 (13:14 +0100)
commit5139cbc0c6e4bf2fcffc9a7ed4350bf6985bc561
treec129fd25103f835224f7830e8f78735a349015d3
parentcab345f9d51943898e406275f9607c145adb1877
thermal: core: fix some possible name leaks in error paths

[ Upstream commit 4748f9687caaeefab8578285b97b2f30789fc4b4 ]

In some error paths before device_register(), the names allocated
by dev_set_name() are not freed. Move dev_set_name() front to
device_register(), so the name can be freed while calling
put_device().

Fixes: 1dd7128b839f ("thermal/core: Fix null pointer dereference in thermal_release()")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/thermal/thermal_core.c