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:11:21 +0200
commit786428a1dec2a551fac319d101c550f932ea6988 (patch)
treeaea7175c0821c52fb1c17dac065d63cc4b4c5f2e
parentaacb264d54c412063d5b3e6bcbddc778569e137c (diff)
downloadlinux-stable-786428a1dec2a551fac319d101c550f932ea6988.tar.gz
linux-stable-786428a1dec2a551fac319d101c550f932ea6988.tar.bz2
linux-stable-786428a1dec2a551fac319d101c550f932ea6988.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 e09edb5c5e06..74547323aa83 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -669,6 +669,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;
}