]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
Fix init ordering of /dev/console vs callers of modprobe
authorDavid Howells <dhowells@redhat.com>
Fri, 6 Aug 2010 15:34:43 +0000 (16:34 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 6 Aug 2010 16:17:02 +0000 (09:17 -0700)
Make /dev/console get initialised before any initialisation routine that
invokes modprobe because if modprobe fails, it's going to want to open
/dev/console, presumably to write an error message to.

The problem with that is that if the /dev/console driver is not yet
initialised, the chardev handler will call request_module() to invoke
modprobe, which will fail, because we never compile /dev/console as a
module.

This will lead to a modprobe loop, showing the following in the kernel
log:

request_module: runaway loop modprobe char-major-5-1
request_module: runaway loop modprobe char-major-5-1
request_module: runaway loop modprobe char-major-5-1
request_module: runaway loop modprobe char-major-5-1
request_module: runaway loop modprobe char-major-5-1

This can happen, for example, when the built in md5 module can't find
the built in cryptomgr module (because the latter fails to initialise).
The md5 module comes before the call to tty_init(), presumably because
'crypto' comes before 'drivers' alphabetically.

Fix this by calling tty_init() from chrdev_init().

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/char/mem.c
drivers/char/tty_io.c
fs/char_dev.c
include/linux/tty.h

index f54dab8acdcd6561c742b0541afdae3828dedfd9..a398ecdbd758058104e81223f1cbdfe7057e9a4b 100644 (file)
@@ -916,7 +916,7 @@ static int __init chr_dev_init(void)
                              NULL, devlist[minor].name);
        }
 
-       return 0;
+       return tty_init();
 }
 
 fs_initcall(chr_dev_init);
index d71f0fc34b467c6e7a7c25c0762321f90b7e3fa0..507441ac6edbcdb9c8fcb58da5d0ba34383eadbc 100644 (file)
@@ -3128,7 +3128,7 @@ static struct cdev tty_cdev, console_cdev;
  * Ok, now we can initialize the rest of the tty devices and can count
  * on memory allocations, interrupts etc..
  */
-static int __init tty_init(void)
+int __init tty_init(void)
 {
        cdev_init(&tty_cdev, &tty_fops);
        if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
@@ -3149,4 +3149,4 @@ static int __init tty_init(void)
 #endif
        return 0;
 }
-module_init(tty_init);
+
index d6db933df2b27ce43c0fe31d6e35bb0968598891..f80a4f25123c3fa912daa1eb4080e69dab3d58fb 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/cdev.h>
 #include <linux/mutex.h>
 #include <linux/backing-dev.h>
+#include <linux/tty.h>
 
 #include "internal.h"
 
index 931078b73226a729f62b82938747c940b1593084..7802a243ee1372dfff07f1dd6c2b294abeddfb9c 100644 (file)
@@ -552,6 +552,9 @@ static inline void tty_audit_push_task(struct task_struct *tsk,
 }
 #endif
 
+/* tty_io.c */
+extern int __init tty_init(void);
+
 /* tty_ioctl.c */
 extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
                       unsigned int cmd, unsigned long arg);