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: v4.19.249~41 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c7757262693162244207158ff55085b9f4113dd3;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 4cd9ea5c75be7..c69c755bf5538 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c @@ -663,6 +663,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; }