mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.cz>
Cc: Peter Hurley <peter@hurleysoftware.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v4 1/3] vt: fix check for system/busy console drivers when unregistering them
Date: Tue, 16 Dec 2014 00:15:59 +0200	[thread overview]
Message-ID: <1418681761-3709-1-git-send-email-imre.deak@intel.com> (raw)

The default console driver (conswitchp) and busy drivers bound to a
console (as reported by con_is_bound()) shouldn't be unregistered.
System console drivers (without the CON_DRIVER_FLAG_MODULE flag) can be
unregistered, provided they are neither default nor busy. The current
code checks for the CON_DRIVER_FLAG_INIT flag but this doesn't make
sense: this flag is set for a driver whenever its associated console's
con_startup() function is called, which first happens when the console
driver is registered (so before the console gets bound) and gets cleared
when the console gets unbound. The purpose of this flag is to show if we
need to call con_startup() on a console before we use it.

Based on the above, do_unregister_con_driver() in its current form will
allow unregistering a console driver only if it was never bound, but
will refuse to unregister one that was bound and later unbound.

Fix this by dropping the CON_DRIVER_FLAG_INIT check, allowing
unregistering of any console driver provided that it's not the default
one and it's not busy.

v2:
- reword the third paragraph to clarify how the fix works (Peter Hurley)
v3:
- unchanged
v4:
- Allow unregistering a system console driver too, needed by i915 to
  unregister vgacon. Update commit description accordingly. (Daniel)

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/tty/vt/vt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index f3fbbbc..9c046fb 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -3665,8 +3665,7 @@ int do_unregister_con_driver(const struct consw *csw)
 	for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
 		struct con_driver *con_driver = &registered_con_driver[i];
 
-		if (con_driver->con == csw &&
-		    con_driver->flag & CON_DRIVER_FLAG_INIT) {
+		if (con_driver->con == csw) {
 			vtconsole_deinit_device(con_driver);
 			device_destroy(vtconsole_class,
 				       MKDEV(0, con_driver->node));
-- 
1.8.4


             reply	other threads:[~2014-12-15 22:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-15 22:15 Imre Deak [this message]
2014-12-15 22:16 ` [PATCH v4 2/3] vt: fix locking around vt_bind/vt_unbind Imre Deak
2014-12-16  7:37   ` Daniel Vetter
2014-12-15 22:16 ` [PATCH v4 3/3] vt: fix console lock vs. kernfs s_active lock order Imre Deak
2014-12-16  7:53   ` Daniel Vetter
2014-12-16 10:23     ` Imre Deak
2014-12-16 12:50       ` Peter Hurley
2014-12-16 13:45         ` Daniel Vetter
2014-12-16 14:38         ` Imre Deak
2014-12-16 15:00           ` Peter Hurley
2014-12-16 15:10             ` Daniel Vetter
2014-12-16 15:48               ` Peter Hurley
2014-12-16 16:22             ` Imre Deak
2014-12-16 17:15               ` Peter Hurley
2014-12-16 17:42                 ` Daniel Vetter
2015-03-26 19:59                   ` Jesse Barnes
2015-03-26 21:01                     ` Greg Kroah-Hartman
2015-03-26 21:05                       ` Imre Deak
2015-03-27  7:46                         ` Daniel Vetter
2015-03-31 15:59                           ` Greg Kroah-Hartman
2015-04-01 18:06                             ` [PATCH] " Imre Deak
2014-12-16  7:35 ` [PATCH v4 1/3] vt: fix check for system/busy console drivers when unregistering them Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418681761-3709-1-git-send-email-imre.deak@intel.com \
    --to=imre.deak@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter@hurleysoftware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome