platform/x86: intel_scu_ipc: fix possible name leak in __intel_scu_ipc_register()
authorYang Yingliang <yangyingliang@huawei.com>
Thu, 8 Dec 2022 15:19:16 +0000 (23:19 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:14:05 +0000 (13:14 +0100)
commit50af0ba3e163f71348c6a2e7f3a3e244efa76c53
tree757c4fc7372672b794fce0d4243517eca80fc665
parent3cf81501356c9e898ad94b2369ffc805f83f7d7b
platform/x86: intel_scu_ipc: fix possible name leak in __intel_scu_ipc_register()

[ Upstream commit 0b3d0cb7c0bed2fd6454f77ed75e7a662c6efd12 ]

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: 54b34aa0a729 ("platform/x86: intel_scu_ipc: Split out SCU IPC functionality from the SCU driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221208151916.2404977-1-yangyingliang@huawei.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/platform/x86/intel_scu_ipc.c