diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-22 23:10:48 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-22 23:10:48 -0400 |
commit | 3aa536d9aafc2806dd3439114e25b253086312a9 (patch) | |
tree | 9f98e29ba0d1176106157c9039cef15155a53621 | |
parent | f1894d838f4bce37297f04b7ed7aac1e6ed7717a (diff) | |
parent | e9003c9cfaa17d26991688268b04244adb67ee2b (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
-rw-r--r-- | drivers/input/rmi4/rmi_f12.c | 9 | ||||
-rw-r--r-- | drivers/input/touchscreen/tsc2004.c | 7 | ||||
-rw-r--r-- | drivers/input/touchscreen/tsc2005.c | 7 | ||||
-rw-r--r-- | drivers/input/touchscreen/tsc200x-core.c | 15 | ||||
-rw-r--r-- | drivers/input/touchscreen/tsc200x-core.h | 2 | ||||
-rw-r--r-- | drivers/tty/vt/keyboard.c | 30 |
6 files changed, 39 insertions, 31 deletions
diff --git a/drivers/input/rmi4/rmi_f12.c b/drivers/input/rmi4/rmi_f12.c index 8dd3fb5e1f94..88e91559c84e 100644 --- a/drivers/input/rmi4/rmi_f12.c +++ b/drivers/input/rmi4/rmi_f12.c | |||
@@ -66,7 +66,7 @@ static int rmi_f12_read_sensor_tuning(struct f12_data *f12) | |||
66 | struct rmi_device *rmi_dev = fn->rmi_dev; | 66 | struct rmi_device *rmi_dev = fn->rmi_dev; |
67 | int ret; | 67 | int ret; |
68 | int offset; | 68 | int offset; |
69 | u8 buf[14]; | 69 | u8 buf[15]; |
70 | int pitch_x = 0; | 70 | int pitch_x = 0; |
71 | int pitch_y = 0; | 71 | int pitch_y = 0; |
72 | int clip_x_low = 0; | 72 | int clip_x_low = 0; |
@@ -86,9 +86,10 @@ static int rmi_f12_read_sensor_tuning(struct f12_data *f12) | |||
86 | 86 | ||
87 | offset = rmi_register_desc_calc_reg_offset(&f12->control_reg_desc, 8); | 87 | offset = rmi_register_desc_calc_reg_offset(&f12->control_reg_desc, 8); |
88 | 88 | ||
89 | if (item->reg_size > 14) { | 89 | if (item->reg_size > sizeof(buf)) { |
90 | dev_err(&fn->dev, "F12 control8 should be 14 bytes, not: %ld\n", | 90 | dev_err(&fn->dev, |
91 | item->reg_size); | 91 | "F12 control8 should be no bigger than %zd bytes, not: %ld\n", |
92 | sizeof(buf), item->reg_size); | ||
92 | return -ENODEV; | 93 | return -ENODEV; |
93 | } | 94 | } |
94 | 95 | ||
diff --git a/drivers/input/touchscreen/tsc2004.c b/drivers/input/touchscreen/tsc2004.c index 7295c198aa08..6fe55d598fac 100644 --- a/drivers/input/touchscreen/tsc2004.c +++ b/drivers/input/touchscreen/tsc2004.c | |||
@@ -22,6 +22,11 @@ | |||
22 | #include <linux/regmap.h> | 22 | #include <linux/regmap.h> |
23 | #include "tsc200x-core.h" | 23 | #include "tsc200x-core.h" |
24 | 24 | ||
25 | static const struct input_id tsc2004_input_id = { | ||
26 | .bustype = BUS_I2C, | ||
27 | .product = 2004, | ||
28 | }; | ||
29 | |||
25 | static int tsc2004_cmd(struct device *dev, u8 cmd) | 30 | static int tsc2004_cmd(struct device *dev, u8 cmd) |
26 | { | 31 | { |
27 | u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd; | 32 | u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd; |
@@ -42,7 +47,7 @@ static int tsc2004_probe(struct i2c_client *i2c, | |||
42 | const struct i2c_device_id *id) | 47 | const struct i2c_device_id *id) |
43 | 48 | ||
44 | { | 49 | { |
45 | return tsc200x_probe(&i2c->dev, i2c->irq, BUS_I2C, | 50 | return tsc200x_probe(&i2c->dev, i2c->irq, &tsc2004_input_id, |
46 | devm_regmap_init_i2c(i2c, &tsc200x_regmap_config), | 51 | devm_regmap_init_i2c(i2c, &tsc200x_regmap_config), |
47 | tsc2004_cmd); | 52 | tsc2004_cmd); |
48 | } | 53 | } |
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c index b9f593dfd2ef..f2c5f0e47f77 100644 --- a/drivers/input/touchscreen/tsc2005.c +++ b/drivers/input/touchscreen/tsc2005.c | |||
@@ -24,6 +24,11 @@ | |||
24 | #include <linux/regmap.h> | 24 | #include <linux/regmap.h> |
25 | #include "tsc200x-core.h" | 25 | #include "tsc200x-core.h" |
26 | 26 | ||
27 | static const struct input_id tsc2005_input_id = { | ||
28 | .bustype = BUS_SPI, | ||
29 | .product = 2005, | ||
30 | }; | ||
31 | |||
27 | static int tsc2005_cmd(struct device *dev, u8 cmd) | 32 | static int tsc2005_cmd(struct device *dev, u8 cmd) |
28 | { | 33 | { |
29 | u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd; | 34 | u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd; |
@@ -62,7 +67,7 @@ static int tsc2005_probe(struct spi_device *spi) | |||
62 | if (error) | 67 | if (error) |
63 | return error; | 68 | return error; |
64 | 69 | ||
65 | return tsc200x_probe(&spi->dev, spi->irq, BUS_SPI, | 70 | return tsc200x_probe(&spi->dev, spi->irq, &tsc2005_input_id, |
66 | devm_regmap_init_spi(spi, &tsc200x_regmap_config), | 71 | devm_regmap_init_spi(spi, &tsc200x_regmap_config), |
67 | tsc2005_cmd); | 72 | tsc2005_cmd); |
68 | } | 73 | } |
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c index 15240c1ee850..dfa7f1c4f545 100644 --- a/drivers/input/touchscreen/tsc200x-core.c +++ b/drivers/input/touchscreen/tsc200x-core.c | |||
@@ -450,7 +450,7 @@ static void tsc200x_close(struct input_dev *input) | |||
450 | mutex_unlock(&ts->mutex); | 450 | mutex_unlock(&ts->mutex); |
451 | } | 451 | } |
452 | 452 | ||
453 | int tsc200x_probe(struct device *dev, int irq, __u16 bustype, | 453 | int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, |
454 | struct regmap *regmap, | 454 | struct regmap *regmap, |
455 | int (*tsc200x_cmd)(struct device *dev, u8 cmd)) | 455 | int (*tsc200x_cmd)(struct device *dev, u8 cmd)) |
456 | { | 456 | { |
@@ -547,9 +547,18 @@ int tsc200x_probe(struct device *dev, int irq, __u16 bustype, | |||
547 | snprintf(ts->phys, sizeof(ts->phys), | 547 | snprintf(ts->phys, sizeof(ts->phys), |
548 | "%s/input-ts", dev_name(dev)); | 548 | "%s/input-ts", dev_name(dev)); |
549 | 549 | ||
550 | input_dev->name = "TSC200X touchscreen"; | 550 | if (tsc_id->product == 2004) { |
551 | input_dev->name = "TSC200X touchscreen"; | ||
552 | } else { | ||
553 | input_dev->name = devm_kasprintf(dev, GFP_KERNEL, | ||
554 | "TSC%04d touchscreen", | ||
555 | tsc_id->product); | ||
556 | if (!input_dev->name) | ||
557 | return -ENOMEM; | ||
558 | } | ||
559 | |||
551 | input_dev->phys = ts->phys; | 560 | input_dev->phys = ts->phys; |
552 | input_dev->id.bustype = bustype; | 561 | input_dev->id = *tsc_id; |
553 | input_dev->dev.parent = dev; | 562 | input_dev->dev.parent = dev; |
554 | input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); | 563 | input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); |
555 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); | 564 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
diff --git a/drivers/input/touchscreen/tsc200x-core.h b/drivers/input/touchscreen/tsc200x-core.h index 7a482d102614..49a63a3c6840 100644 --- a/drivers/input/touchscreen/tsc200x-core.h +++ b/drivers/input/touchscreen/tsc200x-core.h | |||
@@ -70,7 +70,7 @@ | |||
70 | extern const struct regmap_config tsc200x_regmap_config; | 70 | extern const struct regmap_config tsc200x_regmap_config; |
71 | extern const struct dev_pm_ops tsc200x_pm_ops; | 71 | extern const struct dev_pm_ops tsc200x_pm_ops; |
72 | 72 | ||
73 | int tsc200x_probe(struct device *dev, int irq, __u16 bustype, | 73 | int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, |
74 | struct regmap *regmap, | 74 | struct regmap *regmap, |
75 | int (*tsc200x_cmd)(struct device *dev, u8 cmd)); | 75 | int (*tsc200x_cmd)(struct device *dev, u8 cmd)); |
76 | int tsc200x_remove(struct device *dev); | 76 | int tsc200x_remove(struct device *dev); |
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 | ||
367 | static void do_compute_shiftstate(void) | 367 | static 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 | ||