提交 9a5e1191 编写于 作者: C chengkaitao 提交者: Zheng Zengkai

virtio-mmio: fix missing put_device() when vm_cmdline_parent registration failed

stable inclusion
from stable-v5.10.124
commit 6c18f47f47d4e5df42db2300bf4200fd0a2c7a4f
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6E7

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

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

[ Upstream commit a58a7f97 ]

The reference must be released when device_register(&vm_cmdline_parent)
failed. Add the corresponding 'put_device()' in the error handling path.
Signed-off-by: Nchengkaitao <pilgrimtao@gmail.com>
Message-Id: <20220602005542.16489-1-chengkaitao@didiglobal.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
Acked-by: NJason Wang <jasowang@redhat.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 4c54a4ec
...@@ -689,6 +689,7 @@ static int vm_cmdline_set(const char *device, ...@@ -689,6 +689,7 @@ static int vm_cmdline_set(const char *device,
if (!vm_cmdline_parent_registered) { if (!vm_cmdline_parent_registered) {
err = device_register(&vm_cmdline_parent); err = device_register(&vm_cmdline_parent);
if (err) { if (err) {
put_device(&vm_cmdline_parent);
pr_err("Failed to register parent device!\n"); pr_err("Failed to register parent device!\n");
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册