Skip to contentSkip to conversation

vt: Fix module ref counting

PATCH New Antonino A. Daplas 1 participant 1 message Jun 25, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vt: Fix module ref counting

Unbinding a console driver does not set the module ref count to zero. This is due to the following:

1. vgacon may point the default console driver pointer (conswitchp) to dummycon, so when a module_put(conswitchp->owner) is done, it decrements the ref count of dummycon, not fbcon.

2. Pass a unique minor number (con_driver->node) to class_device_create(), otherwise, class_device_destroy() may get confused.

---

 drivers/char/vt.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
drivers/char/vt.c +12 -4
index bd667d9..714d95f 100644
@@ -2873,8 +2873,15 @@ static int unbind_con_driver(const struc
 	}
 
 	if (!con_is_bound(defcsw)) {
+		const struct consw *defconsw = conswitchp;
+
 		defcsw->con_startup();
 		con_back->flag |= CON_DRIVER_FLAG_INIT;
+		/*
+		 * vgacon may change the default driver to point
+		 * to dummycon, we restore it here...
+		 */
+		conswitchp = defconsw;
 	}
 
 	if (!con_is_bound(csw))
@@ -3131,8 +3138,8 @@ int register_con_driver(const struct con
 		goto err;
 
 	con_driver->class_dev = class_device_create(vtconsole_class, NULL,
-						    MKDEV(0, 0), NULL,
-						    "vtcon%i",
+						    MKDEV(0, con_driver->node),
+						    NULL, "vtcon%i",
 						    con_driver->node);
 
 	if (IS_ERR(con_driver->class_dev)) {
@@ -3177,7 +3184,8 @@ int unregister_con_driver(const struct c
 		if (con_driver->con == csw &&
 		    con_driver->flag & CON_DRIVER_FLAG_MODULE) {
 			vtconsole_deinit_class_device(con_driver);
-			class_device_destroy(vtconsole_class, MKDEV(0, 0));
+			class_device_destroy(vtconsole_class,
+					     MKDEV(0, con_driver->node));
 			con_driver->con = NULL;
 			con_driver->desc = NULL;
 			con_driver->class_dev = NULL;
@@ -3241,7 +3249,7 @@ static int __init vtconsole_class_init(v
 		if (con->con && !con->class_dev) {
 			con->class_dev =
 				class_device_create(vtconsole_class, NULL,
-						    MKDEV(0, 0), NULL,
+						    MKDEV(0, con->node), NULL,
 						    "vtcon%i", con->node);
 
 			if (IS_ERR(con->class_dev)) {

Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642