Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1393490 > unrolled thread

[PATCH 1/2] tty: vt, return error when con_startup fails

Started byJiri Slaby <jslaby@suse.cz>
First post2016-05-03 17:10 +0200
Last post2016-05-03 17:10 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2] tty: vt, return error when con_startup fails Jiri Slaby <jslaby@suse.cz> - 2016-05-03 17:10 +0200
    [PATCH 2/2] tty: vt, finish looping on duplicate Jiri Slaby <jslaby@suse.cz> - 2016-05-03 17:10 +0200

#1393490 — [PATCH 1/2] tty: vt, return error when con_startup fails

FromJiri Slaby <jslaby@suse.cz>
Date2016-05-03 17:10 +0200
Subject[PATCH 1/2] tty: vt, return error when con_startup fails
Message-ID<ruK7x-1Tc-45@gated-at.bofh.it>
When csw->con_startup() fails in do_register_con_driver, we return no
error (i.e. 0). This was changed back in 2006 by commit 3e795de763.
Before that we used to return -ENODEV.

So fix the return value to be -ENODEV in that case again.

Fixes: 3e795de763 ("VT binding: Add binding/unbinding support for the VT console")
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reported-by: "Dan Carpenter" <dan.carpenter@oracle.com>
---
 drivers/tty/vt/vt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 8f9f8ed3ed09..3ed1ae211acc 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -3594,9 +3594,10 @@ static int do_register_con_driver(const struct consw *csw, int first, int last)
 		goto err;
 
 	desc = csw->con_startup();
-
-	if (!desc)
+	if (!desc) {
+		retval = -ENODEV;
 		goto err;
+	}
 
 	retval = -EINVAL;
 
-- 
2.8.2

[toc] | [next] | [standalone]


#1393492 — [PATCH 2/2] tty: vt, finish looping on duplicate

FromJiri Slaby <jslaby@suse.cz>
Date2016-05-03 17:10 +0200
Subject[PATCH 2/2] tty: vt, finish looping on duplicate
Message-ID<ruK7x-1Tc-49@gated-at.bofh.it>
In reply to#1393490
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>
---
 drivers/tty/vt/vt.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 3ed1ae211acc..dc125322f48f 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -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;
-- 
2.8.2

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web