提交 ace8a49a 编写于 作者: Y Yang Yingliang 提交者: openeuler-sync-bot

xen/pcpu: fix possible memory leak in register_pcpu()

stable inclusion
from stable-v5.10.156
commit bb9924a6edd9d4a9ef83a5f337af60f8a7a68f98
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7MCG1

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=bb9924a6edd9d4a9ef83a5f337af60f8a7a68f98

--------------------------------

[ Upstream commit da36a2a7 ]

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: f65c9bb3 ("xen/pcpu: Xen physical cpus online/offline sys interface")
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NJuergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20221110152441.401630-1-yangyingliang@huawei.comSigned-off-by: NJuergen Gross <jgross@suse.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
(cherry picked from commit 480c7d9a)
上级 1e311379
......@@ -228,7 +228,7 @@ static int register_pcpu(struct pcpu *pcpu)
err = device_register(dev);
if (err) {
pcpu_release(dev);
put_device(dev);
return err;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册