Sophie

Sophie

distrib > PLD > ac > amd64 > by-pkgid > 950ec4453099b5125884e99014f11757 > files > 89

kernel24-2.4.34-1.src.rpm

diff -urNp linux-1255/drivers/input/input.c linux-1261/drivers/input/input.c
--- linux-1255/drivers/input/input.c	
+++ linux-1261/drivers/input/input.c	
@@ -34,6 +34,7 @@
 #include <linux/input.h>
 #include <linux/module.h>
 #include <linux/random.h>
+#include <linux/kmod.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
 MODULE_DESCRIPTION("Input layer module");
@@ -370,12 +371,20 @@ void input_unregister_handler(struct inp
 
 static int input_open_file(struct inode *inode, struct file *file)
 {
-	struct input_handler *handler = input_table[MINOR(inode->i_rdev) >> 5];
-	struct file_operations *old_fops, *new_fops = NULL;
+	struct input_handler *handler;
+	struct file_operations *old_fops, *new_fops;
+	unsigned int minor = MINOR(inode->i_rdev);
 	int err;
 
-	/* No load-on-demand here? */
-	if (!handler || !(new_fops = fops_get(handler->fops)))
+	/* XXX Are we sure there's no locking problem here? */
+	if (!(handler = input_table[minor >> 5])) {
+		char modnam[sizeof("char-major-00000-000000000")];
+		sprintf(modnam, "char-major-%d-%d", INPUT_MAJOR, minor & ~0x1f);
+		request_module(modnam);
+		if (!(handler = input_table[minor >> 5]))
+			return -ENODEV;
+	}
+	if (!(new_fops = fops_get(handler->fops)))
 		return -ENODEV;
 
 	/*