Commit 31d1d48e199e99077fb30f6fb9a793be7bec756f

Authored by David Howells
Committed by Linus Torvalds
1 parent 1e456a1243

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>

Showing 4 changed files with 7 additions and 3 deletions Side-by-side Diff

... ... @@ -916,7 +916,7 @@
916 916 NULL, devlist[minor].name);
917 917 }
918 918  
919   - return 0;
  919 + return tty_init();
920 920 }
921 921  
922 922 fs_initcall(chr_dev_init);
drivers/char/tty_io.c
... ... @@ -3128,7 +3128,7 @@
3128 3128 * Ok, now we can initialize the rest of the tty devices and can count
3129 3129 * on memory allocations, interrupts etc..
3130 3130 */
3131   -static int __init tty_init(void)
  3131 +int __init tty_init(void)
3132 3132 {
3133 3133 cdev_init(&tty_cdev, &tty_fops);
3134 3134 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
... ... @@ -3149,5 +3149,4 @@
3149 3149 #endif
3150 3150 return 0;
3151 3151 }
3152   -module_init(tty_init);
... ... @@ -20,6 +20,7 @@
20 20 #include <linux/cdev.h>
21 21 #include <linux/mutex.h>
22 22 #include <linux/backing-dev.h>
  23 +#include <linux/tty.h>
23 24  
24 25 #include "internal.h"
25 26  
... ... @@ -552,6 +552,9 @@
552 552 }
553 553 #endif
554 554  
  555 +/* tty_io.c */
  556 +extern int __init tty_init(void);
  557 +
555 558 /* tty_ioctl.c */
556 559 extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
557 560 unsigned int cmd, unsigned long arg);