diff options
author | Alexey Khoroshilov <khoroshilov@ispras.ru> | 2012-09-01 15:49:37 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-09-28 01:35:13 -0400 |
commit | 33e1afc3d82697599ccc8dc8f2fa44ffff5ae329 (patch) | |
tree | b4b1c2b403a9b8a9a84c2a7d90e234b0703bec63 /drivers/char/virtio_console.c | |
parent | 5b8fa822b71fa91b17c9fb38bcca31e771f7650d (diff) |
virtio: console: fix error handling in init() function
If register_virtio_driver() fails, virtio-ports class is not destroyed.
The patch adds error handling of register_virtio_driver().
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/char/virtio_console.c')
-rw-r--r-- | drivers/char/virtio_console.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index e88f84390428..8ab9c3d4bf13 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -2099,7 +2099,17 @@ static int __init init(void) | |||
2099 | INIT_LIST_HEAD(&pdrvdata.consoles); | 2099 | INIT_LIST_HEAD(&pdrvdata.consoles); |
2100 | INIT_LIST_HEAD(&pdrvdata.portdevs); | 2100 | INIT_LIST_HEAD(&pdrvdata.portdevs); |
2101 | 2101 | ||
2102 | return register_virtio_driver(&virtio_console); | 2102 | err = register_virtio_driver(&virtio_console); |
2103 | if (err < 0) { | ||
2104 | pr_err("Error %d registering virtio driver\n", err); | ||
2105 | goto free; | ||
2106 | } | ||
2107 | return 0; | ||
2108 | free: | ||
2109 | if (pdrvdata.debugfs_dir) | ||
2110 | debugfs_remove_recursive(pdrvdata.debugfs_dir); | ||
2111 | class_destroy(pdrvdata.class); | ||
2112 | return err; | ||
2103 | } | 2113 | } |
2104 | 2114 | ||
2105 | static void __exit fini(void) | 2115 | static void __exit fini(void) |