cfq-iosched: fix an oops caused by slab leak
[safe/jmp/linux-2.6] / drivers / serial / kgdboc.c
index ecef6e1..a9a94ae 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/kgdb.h>
 #include <linux/kdb.h>
 #include <linux/tty.h>
+#include <linux/console.h>
 
 #define MAX_CONFIG_LEN         40
 
@@ -93,12 +94,14 @@ static int configure_kgdboc(void)
        int tty_line = 0;
        int err;
        char *cptr = config;
+       struct console *cons;
 
        err = kgdboc_option_setup(config);
        if (err || !strlen(config) || isspace(config[0]))
                goto noconfig;
 
        err = -ENODEV;
+       kgdboc_io_ops.is_console = 0;
        kgdb_tty_driver = NULL;
 
        if (kgdboc_register_kbd(&cptr))
@@ -108,6 +111,17 @@ static int configure_kgdboc(void)
        if (!p)
                goto noconfig;
 
+       cons = console_drivers;
+       while (cons) {
+               int idx;
+               if (cons->device && cons->device(cons, &idx) == p &&
+                   idx == tty_line) {
+                       kgdboc_io_ops.is_console = 1;
+                       break;
+               }
+               cons = cons->next;
+       }
+
        kgdb_tty_driver = p;
        kgdb_tty_line = tty_line;
 
@@ -209,6 +223,25 @@ static struct kgdb_io kgdboc_io_ops = {
        .post_exception         = kgdboc_post_exp_handler,
 };
 
+#ifdef CONFIG_KGDB_SERIAL_CONSOLE
+/* This is only available if kgdboc is a built in for early debugging */
+int __init kgdboc_early_init(char *opt)
+{
+       /* save the first character of the config string because the
+        * init routine can destroy it.
+        */
+       char save_ch;
+
+       kgdboc_option_setup(opt);
+       save_ch = config[0];
+       init_kgdboc();
+       config[0] = save_ch;
+       return 0;
+}
+
+early_param("ekgdboc", kgdboc_early_init);
+#endif /* CONFIG_KGDB_SERIAL_CONSOLE */
+
 module_init(init_kgdboc);
 module_exit(cleanup_kgdboc);
 module_param_call(kgdboc, param_set_kgdboc_var, param_get_string, &kps, 0644);