aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2010-08-06 11:34:43 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-06 12:17:02 -0400
commit31d1d48e199e99077fb30f6fb9a793be7bec756f (patch)
tree7f9dddbd89030765f6544e5820c401849193dca8
parent1e456a124353a753e9d1fadfbf5cd459c2f197ae (diff)
Fix init ordering of /dev/console vs callers of modprobe
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>
-rw-r--r--drivers/char/mem.c2
-rw-r--r--drivers/char/tty_io.c4
-rw-r--r--fs/char_dev.c1
-rw-r--r--include/linux/tty.h3
4 files changed, 7 insertions, 3 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index f54dab8acdcd..a398ecdbd758 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -916,7 +916,7 @@ static int __init chr_dev_init(void)
916 NULL, devlist[minor].name); 916 NULL, devlist[minor].name);
917 } 917 }
918 918
919 return 0; 919 return tty_init();
920} 920}
921 921
922fs_initcall(chr_dev_init); 922fs_initcall(chr_dev_init);
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index d71f0fc34b46..507441ac6edb 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -3128,7 +3128,7 @@ static struct cdev tty_cdev, console_cdev;
3128 * Ok, now we can initialize the rest of the tty devices and can count 3128 * Ok, now we can initialize the rest of the tty devices and can count
3129 * on memory allocations, interrupts etc.. 3129 * on memory allocations, interrupts etc..
3130 */ 3130 */
3131static int __init tty_init(void) 3131int __init tty_init(void)
3132{ 3132{
3133 cdev_init(&tty_cdev, &tty_fops); 3133 cdev_init(&tty_cdev, &tty_fops);
3134 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || 3134 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
@@ -3149,4 +3149,4 @@ static int __init tty_init(void)
3149#endif 3149#endif
3150 return 0; 3150 return 0;
3151} 3151}
3152module_init(tty_init); 3152
diff --git a/fs/char_dev.c b/fs/char_dev.c
index d6db933df2b2..f80a4f25123c 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -20,6 +20,7 @@
20#include <linux/cdev.h> 20#include <linux/cdev.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/backing-dev.h> 22#include <linux/backing-dev.h>
23#include <linux/tty.h>
23 24
24#include "internal.h" 25#include "internal.h"
25 26
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 931078b73226..7802a243ee13 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -552,6 +552,9 @@ static inline void tty_audit_push_task(struct task_struct *tsk,
552} 552}
553#endif 553#endif
554 554
555/* tty_io.c */
556extern int __init tty_init(void);
557
555/* tty_ioctl.c */ 558/* tty_ioctl.c */
556extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, 559extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
557 unsigned int cmd, unsigned long arg); 560 unsigned int cmd, unsigned long arg);