Fix the panic on atkbdc_configure() failure
authorYONETANI Tomokazu <y0netan1@dragonflybsd.org>
Sat, 10 Dec 2011 11:43:42 +0000 (20:43 +0900)
committerYONETANI Tomokazu <y0netan1@dragonflybsd.org>
Sun, 11 Dec 2011 08:28:05 +0000 (17:28 +0900)
kbd_unregister() expects the caller to hold kb_lock because it's mainly
called by kbd_term_t routine.

sys/dev/misc/kbd/atkbd.c
sys/dev/misc/kbd/kbd.c

index 2f0a895..74c7917 100644 (file)
@@ -290,6 +290,7 @@ atkbd_configure(int flags)
                i = kbd_find_keyboard(ATKBD_DRIVER_NAME, ATKBD_DEFAULT);
                if (i >= 0) {
                        kbd = kbd_get_keyboard(i);
+                       KBD_ALWAYS_LOCK(kbd);
                        kbd_unregister(kbd);
                        kbd = NULL; /* huh? */
                }
index 3c9ecc5..47432e0 100644 (file)
@@ -293,6 +293,7 @@ kbd_unregister(keyboard_t *kbd)
 {
        int error;
 
+       KBD_LOCK_ASSERT(kbd);
        lwkt_gettoken(&tty_token);
        if ((kbd->kb_index < 0) || (kbd->kb_index >= keyboards)) {
                lwkt_reltoken(&tty_token);