Avoids races of high-level syscons code with the sckbdevent handler. Made for FreeBSD 7.x (syscons.c 1.453.2.1); was tested on 7.0-PRERELEASE, 7.0-STABLE, 7.0-RELEASE-p3 and 7.1-PRERELEASE (up to the revision 1.453.2.3 of syscons.c). --- sys/dev/syscons/syscons.c.orig 2008-09-23 11:46:45.000000000 +0400 +++ sys/dev/syscons/syscons.c 2008-09-23 12:16:32.000000000 +0400 @@ -1590,6 +1592,7 @@ int s = spltty(); /* block sckbdevent and scrn_timer while we poll */ int c; + mtx_lock(&Giant); /* assert(sc_console != NULL) */ /* @@ -1601,11 +1604,13 @@ sccnupdate(scp); if (fkeycp < fkey.len) { + mtx_unlock(&Giant); splx(s); return fkey.str[fkeycp++]; } if (scp->sc->kbd == NULL) { + mtx_unlock(&Giant); splx(s); return -1; } @@ -1628,6 +1633,7 @@ scp->kbd_mode = cur_mode; kbd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode); kbd_disable(scp->sc->kbd); + mtx_unlock(&Giant); splx(s); switch (KEYFLAGS(c)) {