diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-01-05 20:56:01 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-01-06 03:27:29 -0500 |
commit | 92a3a58788790645c6143b5353ef065fd26110bb (patch) | |
tree | e84cffdd0198641ce02ae65c2449070b21710847 /drivers/input/input.c | |
parent | 4f93df40859cf471774f6ef3ec7f2870c2e8e260 (diff) |
Input: cleanse capabilities bits before registering device
To avoid showing garbage in capability bits, zero out bitmasks absent
from dev->evbit in case driver inadvertently leaves some garbage there.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/input.c')
-rw-r--r-- | drivers/input/input.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c index 910d7be06eff..a31394c1eca8 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -1497,6 +1497,25 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int | |||
1497 | } | 1497 | } |
1498 | EXPORT_SYMBOL(input_set_capability); | 1498 | EXPORT_SYMBOL(input_set_capability); |
1499 | 1499 | ||
1500 | #define INPUT_CLEANSE_BITMASK(dev, type, bits) \ | ||
1501 | do { \ | ||
1502 | if (!test_bit(EV_##type, dev->evbit)) \ | ||
1503 | memset(dev->bits##bit, 0, \ | ||
1504 | sizeof(dev->bits##bit)); \ | ||
1505 | } while (0) | ||
1506 | |||
1507 | static void input_cleanse_bitmasks(struct input_dev *dev) | ||
1508 | { | ||
1509 | INPUT_CLEANSE_BITMASK(dev, KEY, key); | ||
1510 | INPUT_CLEANSE_BITMASK(dev, REL, rel); | ||
1511 | INPUT_CLEANSE_BITMASK(dev, ABS, abs); | ||
1512 | INPUT_CLEANSE_BITMASK(dev, MSC, msc); | ||
1513 | INPUT_CLEANSE_BITMASK(dev, LED, led); | ||
1514 | INPUT_CLEANSE_BITMASK(dev, SND, snd); | ||
1515 | INPUT_CLEANSE_BITMASK(dev, FF, ff); | ||
1516 | INPUT_CLEANSE_BITMASK(dev, SW, sw); | ||
1517 | } | ||
1518 | |||
1500 | /** | 1519 | /** |
1501 | * input_register_device - register device with input core | 1520 | * input_register_device - register device with input core |
1502 | * @dev: device to be registered | 1521 | * @dev: device to be registered |
@@ -1522,6 +1541,9 @@ int input_register_device(struct input_dev *dev) | |||
1522 | /* KEY_RESERVED is not supposed to be transmitted to userspace. */ | 1541 | /* KEY_RESERVED is not supposed to be transmitted to userspace. */ |
1523 | __clear_bit(KEY_RESERVED, dev->keybit); | 1542 | __clear_bit(KEY_RESERVED, dev->keybit); |
1524 | 1543 | ||
1544 | /* Make sure that bitmasks not mentioned in dev->evbit are clean. */ | ||
1545 | input_cleanse_bitmasks(dev); | ||
1546 | |||
1525 | /* | 1547 | /* |
1526 | * If delay and period are pre-set by the driver, then autorepeating | 1548 | * If delay and period are pre-set by the driver, then autorepeating |
1527 | * is handled by the driver itself and we don't do it in input.c. | 1549 | * is handled by the driver itself and we don't do it in input.c. |