Skip to content

Commit

Permalink
virtio-mmio: fix missing put_device() when vm_cmdline_parent registra…
Browse files Browse the repository at this point in the history
…tion failed

[ Upstream commit a58a7f9 ]

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: chengkaitao <pilgrimtao@gmail.com>
Message-Id: <20220602005542.16489-1-chengkaitao@didiglobal.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
chengkaitao authored and gregkh committed Jun 22, 2022
1 parent d539feb commit 6c18f47
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/virtio/virtio_mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ static int vm_cmdline_set(const char *device,
if (!vm_cmdline_parent_registered) {
err = device_register(&vm_cmdline_parent);
if (err) {
put_device(&vm_cmdline_parent);
pr_err("Failed to register parent device!\n");
return err;
}
Expand Down

0 comments on commit 6c18f47

Please sign in to comment.