Skip to content

Commit a58a7f9

Browse files
chengkaitaomstsirkin
authored andcommitted
virtio-mmio: fix missing put_device() when vm_cmdline_parent registration failed
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 <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent 2f72b22 commit a58a7f9

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/virtio/virtio_mmio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ static int vm_cmdline_set(const char *device,
701701
if (!vm_cmdline_parent_registered) {
702702
err = device_register(&vm_cmdline_parent);
703703
if (err) {
704+
put_device(&vm_cmdline_parent);
704705
pr_err("Failed to register parent device!\n");
705706
return err;
706707
}

0 commit comments

Comments
 (0)