]> git.baikalelectronics.ru Git - kernel.git/commit
xen/pcpu: fix possible memory leak in register_pcpu()
authorYang Yingliang <yangyingliang@huawei.com>
Thu, 10 Nov 2022 15:24:41 +0000 (23:24 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Nov 2022 16:42:16 +0000 (17:42 +0100)
commitbe1cb70ebbf23f553a6dcf59ab66733b1f1ee632
tree19885b926eac2a081455ff0151c025edb4068e1d
parent2e54743f30f1d7c1255c550fcc1ab6a0ca417e6a
xen/pcpu: fix possible memory leak in register_pcpu()

[ Upstream commit 51c117165225fb111bbe5498e678d31e60fdfa83 ]

In device_add(), dev_set_name() is called to allocate name, if it returns
error, the name need be freed. As comment of device_register() says, it
should use put_device() to give up the reference in the error path. So fix
this by calling put_device(), then the name can be freed in kobject_cleanup().

Fixes: 390344262d39 ("xen/pcpu: Xen physical cpus online/offline sys interface")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20221110152441.401630-1-yangyingliang@huawei.com
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/xen/pcpu.c