aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/virtio_console.c
diff options
context:
space:
mode:
authorAlexey Khoroshilov <khoroshilov@ispras.ru>2012-09-01 15:49:37 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-05 16:44:04 -0400
commitefda0ad4aa92439d9244d77a13339e23df5e1dc1 (patch)
tree5fe8307deb2c87e2d00d2819d73ef2fc2cb5b3bb /drivers/char/virtio_console.c
parent9a32bb39d6a48d435135695763e5e4a06652eeda (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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char/virtio_console.c')
-rw-r--r--drivers/char/virtio_console.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index cdf2f5451c76..060a672ebb7b 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1941,7 +1941,17 @@ static int __init init(void)
1941 INIT_LIST_HEAD(&pdrvdata.consoles); 1941 INIT_LIST_HEAD(&pdrvdata.consoles);
1942 INIT_LIST_HEAD(&pdrvdata.portdevs); 1942 INIT_LIST_HEAD(&pdrvdata.portdevs);
1943 1943
1944 return register_virtio_driver(&virtio_console); 1944 err = register_virtio_driver(&virtio_console);
1945 if (err < 0) {
1946 pr_err("Error %d registering virtio driver\n", err);
1947 goto free;
1948 }
1949 return 0;
1950free:
1951 if (pdrvdata.debugfs_dir)
1952 debugfs_remove_recursive(pdrvdata.debugfs_dir);
1953 class_destroy(pdrvdata.class);
1954 return err;
1945} 1955}
1946 1956
1947static void __exit fini(void) 1957static void __exit fini(void)