Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Nov 2017 22:15:19 +0000 (UTC)
From:      Vladimir Kondratyev <wulf@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r325295 - head/sys/dev/evdev
Message-ID:  <201711012215.vA1MFJhp048740@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: wulf
Date: Wed Nov  1 22:15:19 2017
New Revision: 325295
URL: https://svnweb.freebsd.org/changeset/base/325295

Log:
  evdev: Lock Giant around keyboard ioctls
  
  This fixes turning ukbd(4) LEDs on/off with evdev interface as well
  
  Reviewed by:		gonzo
  Approved by:		gonzo (mentor)
  MFC after:		2 weeks
  Differential Revision:	https://reviews.freebsd.org/D12676

Modified:
  head/sys/dev/evdev/evdev_utils.c

Modified: head/sys/dev/evdev/evdev_utils.c
==============================================================================
--- head/sys/dev/evdev/evdev_utils.c	Wed Nov  1 22:09:10 2017	(r325294)
+++ head/sys/dev/evdev/evdev_utils.c	Wed Nov  1 22:15:19 2017	(r325295)
@@ -32,7 +32,9 @@
 #include <sys/conf.h>
 #include <sys/kbio.h>
 #include <sys/kernel.h>
+#include <sys/lock.h>
 #include <sys/malloc.h>
+#include <sys/mutex.h>
 #include <sys/systm.h>
 
 #include <dev/evdev/evdev.h>
@@ -314,19 +316,26 @@ evdev_ev_kbd_event(struct evdev_dev *evdev, void *soft
 					leds |= 1 << i;
 				else
 					leds &= ~(1 << i);
-				if (leds != oleds)
+				if (leds != oleds) {
+					mtx_lock(&Giant);
 					kbdd_ioctl(kbd, KDSETLED,
 					    (caddr_t)&leds);
+					mtx_unlock(&Giant);
+				}
 				break;
 			}
 		}
 	} else if (type == EV_REP && code == REP_DELAY) {
 		delay[0] = value;
 		delay[1] = kbd->kb_delay2;
+		mtx_lock(&Giant);
 		kbdd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay);
+		mtx_unlock(&Giant);
 	} else if (type == EV_REP && code == REP_PERIOD) {
 		delay[0] = kbd->kb_delay1;
 		delay[1] = value;
+		mtx_lock(&Giant);
 		kbdd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay);
+		mtx_unlock(&Giant);
 	}
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711012215.vA1MFJhp048740>