aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/vt
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-07-22 23:10:48 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-07-22 23:10:48 -0400
commit3aa536d9aafc2806dd3439114e25b253086312a9 (patch)
tree9f98e29ba0d1176106157c9039cef15155a53621 /drivers/tty/vt
parentf1894d838f4bce37297f04b7ed7aac1e6ed7717a (diff)
parente9003c9cfaa17d26991688268b04244adb67ee2b (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input fixes from Dmitry Torokhov: "A few more fixes for the input subsystem: - restore naming for tsc2005 touchscreens as some userspace match on it - fix out of bound access in legacy keyboard driver - fixup in RMI4 driver Everything is tagged for stable as well" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: Input: tsc200x - report proper input_dev name tty/vt/keyboard: fix OOB access in do_compute_shiftstate() Input: synaptics-rmi4 - fix maximum size check for F12 control register 8
Diffstat (limited to 'drivers/tty/vt')
-rw-r--r--drivers/tty/vt/keyboard.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index f973bfce5d08..1e93a37e27f0 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -366,34 +366,22 @@ static void to_utf8(struct vc_data *vc, uint c)
366 366
367static void do_compute_shiftstate(void) 367static void do_compute_shiftstate(void)
368{ 368{
369 unsigned int i, j, k, sym, val; 369 unsigned int k, sym, val;
370 370
371 shift_state = 0; 371 shift_state = 0;
372 memset(shift_down, 0, sizeof(shift_down)); 372 memset(shift_down, 0, sizeof(shift_down));
373 373
374 for (i = 0; i < ARRAY_SIZE(key_down); i++) { 374 for_each_set_bit(k, key_down, min(NR_KEYS, KEY_CNT)) {
375 375 sym = U(key_maps[0][k]);
376 if (!key_down[i]) 376 if (KTYP(sym) != KT_SHIFT && KTYP(sym) != KT_SLOCK)
377 continue; 377 continue;
378 378
379 k = i * BITS_PER_LONG; 379 val = KVAL(sym);
380 380 if (val == KVAL(K_CAPSSHIFT))
381 for (j = 0; j < BITS_PER_LONG; j++, k++) { 381 val = KVAL(K_SHIFT);
382
383 if (!test_bit(k, key_down))
384 continue;
385 382
386 sym = U(key_maps[0][k]); 383 shift_down[val]++;
387 if (KTYP(sym) != KT_SHIFT && KTYP(sym) != KT_SLOCK) 384 shift_state |= BIT(val);
388 continue;
389
390 val = KVAL(sym);
391 if (val == KVAL(K_CAPSSHIFT))
392 val = KVAL(K_SHIFT);
393
394 shift_down[val]++;
395 shift_state |= (1 << val);
396 }
397 } 385 }
398} 386}
399 387