From: chengkaitao Date: Thu, 2 Jun 2022 00:55:42 +0000 (+0800) Subject: virtio-mmio: fix missing put_device() when vm_cmdline_parent registration failed X-Git-Tag: v5.10.124~58 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6c18f47f47d4e5df42db2300bf4200fd0a2c7a4f;p=thirdparty%2Fkernel%2Fstable.git 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 Message-Id: <20220602005542.16489-1-chengkaitao@didiglobal.com> Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang Signed-off-by: Sasha Levin --- diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index 238383ff1064c..5c970e6f664c8 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; }