tty: vt, finish looping on duplicate
authorJiri Slaby <jslaby@suse.cz>
Tue, 3 May 2016 15:05:55 +0000 (17:05 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 May 2016 22:59:15 +0000 (15:59 -0700)
When the console is already registered, stop crawling the
registered_con_driver array and return an error immediatelly.

This makes the code more obvious. And we do not need to initialize
retval anymore.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/vt.c

index 3ed1ae2..dc12532 100644 (file)
@@ -3575,7 +3575,7 @@ static int do_register_con_driver(const struct consw *csw, int first, int last)
        struct module *owner = csw->owner;
        struct con_driver *con_driver;
        const char *desc;
-       int i, retval = 0;
+       int i, retval;
 
        WARN_CONSOLE_UNLOCKED();
 
@@ -3586,13 +3586,12 @@ static int do_register_con_driver(const struct consw *csw, int first, int last)
                con_driver = &registered_con_driver[i];
 
                /* already registered */
-               if (con_driver->con == csw)
+               if (con_driver->con == csw) {
                        retval = -EBUSY;
+                       goto err;
+               }
        }
 
-       if (retval)
-               goto err;
-
        desc = csw->con_startup();
        if (!desc) {
                retval = -ENODEV;