summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchengkaitao <pilgrimtao@gmail.com>2022-06-02 08:55:42 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-06-22 14:13:15 +0200
commit6c18f47f47d4e5df42db2300bf4200fd0a2c7a4f (patch)
tree87f9829f820fe953d7e29ce4714731acd9510581
parentd539feb6df5ef94b171f3497583b3dbc1512a347 (diff)
downloadlinux-stable-6c18f47f47d4e5df42db2300bf4200fd0a2c7a4f.tar.gz
linux-stable-6c18f47f47d4e5df42db2300bf4200fd0a2c7a4f.tar.bz2
linux-stable-6c18f47f47d4e5df42db2300bf4200fd0a2c7a4f.zip
virtio-mmio: fix missing put_device() when vm_cmdline_parent registration failed
[ Upstream commit a58a7f97ba11391d2d0d408e0b24f38d86ae748e ] 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>
-rw-r--r--drivers/virtio/virtio_mmio.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index 238383ff1064..5c970e6f664c 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -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;
}