svn commit: r185013 - head/sys/dev/syscons

Maksim Yevmenkin emax at FreeBSD.org
Sun Nov 16 14:39:05 PST 2008


Author: emax
Date: Sun Nov 16 22:39:04 2008
New Revision: 185013
URL: http://svn.freebsd.org/changeset/base/185013

Log:
  More locking for syscons(4). This should prevent races with sckbdevent().
  
  PR:		kern/127446
  Submitted by:	Eygene Ryabinkin rea-fbsd at codelabs dot ru

Modified:
  head/sys/dev/syscons/syscons.c

Modified: head/sys/dev/syscons/syscons.c
==============================================================================
--- head/sys/dev/syscons/syscons.c	Sun Nov 16 21:57:54 2008	(r185012)
+++ head/sys/dev/syscons/syscons.c	Sun Nov 16 22:39:04 2008	(r185013)
@@ -1572,6 +1572,7 @@ sccngetch(int flags)
     int s = spltty();	/* block sckbdevent and scrn_timer while we poll */
     int c;
 
+    mtx_lock(&Giant);
     /* assert(sc_console != NULL) */
 
     /* 
@@ -1583,11 +1584,13 @@ sccngetch(int flags)
     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;
     }
@@ -1610,6 +1613,7 @@ sccngetch(int flags)
     scp->kbd_mode = cur_mode;
     kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
     kbdd_disable(scp->sc->kbd);
+    mtx_unlock(&Giant);
     splx(s);
 
     switch (KEYFLAGS(c)) {


More information about the svn-src-all mailing list