aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/evdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/evdev.c')
-rw-r--r--drivers/input/evdev.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index de055451d1af..bc203485716d 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -738,20 +738,23 @@ static int evdev_handle_set_keycode_v2(struct input_dev *dev, void __user *p)
738 */ 738 */
739static int evdev_handle_get_val(struct evdev_client *client, 739static int evdev_handle_get_val(struct evdev_client *client,
740 struct input_dev *dev, unsigned int type, 740 struct input_dev *dev, unsigned int type,
741 unsigned long *bits, unsigned int max, 741 unsigned long *bits, unsigned int maxbit,
742 unsigned int size, void __user *p, int compat) 742 unsigned int maxlen, void __user *p,
743 int compat)
743{ 744{
744 int ret; 745 int ret;
745 unsigned long *mem; 746 unsigned long *mem;
747 size_t len;
746 748
747 mem = kmalloc(sizeof(unsigned long) * max, GFP_KERNEL); 749 len = BITS_TO_LONGS(maxbit) * sizeof(unsigned long);
750 mem = kmalloc(len, GFP_KERNEL);
748 if (!mem) 751 if (!mem)
749 return -ENOMEM; 752 return -ENOMEM;
750 753
751 spin_lock_irq(&dev->event_lock); 754 spin_lock_irq(&dev->event_lock);
752 spin_lock(&client->buffer_lock); 755 spin_lock(&client->buffer_lock);
753 756
754 memcpy(mem, bits, sizeof(unsigned long) * max); 757 memcpy(mem, bits, len);
755 758
756 spin_unlock(&dev->event_lock); 759 spin_unlock(&dev->event_lock);
757 760
@@ -759,7 +762,7 @@ static int evdev_handle_get_val(struct evdev_client *client,
759 762
760 spin_unlock_irq(&client->buffer_lock); 763 spin_unlock_irq(&client->buffer_lock);
761 764
762 ret = bits_to_user(mem, max, size, p, compat); 765 ret = bits_to_user(mem, maxbit, maxlen, p, compat);
763 if (ret < 0) 766 if (ret < 0)
764 evdev_queue_syn_dropped(client); 767 evdev_queue_syn_dropped(client);
765 768