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.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index c81c79d01d93..370206f987f9 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -481,7 +481,7 @@ static int evdev_release(struct inode *inode, struct file *file)
481 evdev_detach_client(evdev, client); 481 evdev_detach_client(evdev, client);
482 482
483 for (i = 0; i < EV_CNT; ++i) 483 for (i = 0; i < EV_CNT; ++i)
484 kfree(client->evmasks[i]); 484 bitmap_free(client->evmasks[i]);
485 485
486 kvfree(client); 486 kvfree(client);
487 487
@@ -925,17 +925,15 @@ static int evdev_handle_get_val(struct evdev_client *client,
925{ 925{
926 int ret; 926 int ret;
927 unsigned long *mem; 927 unsigned long *mem;
928 size_t len;
929 928
930 len = BITS_TO_LONGS(maxbit) * sizeof(unsigned long); 929 mem = bitmap_alloc(maxbit, GFP_KERNEL);
931 mem = kmalloc(len, GFP_KERNEL);
932 if (!mem) 930 if (!mem)
933 return -ENOMEM; 931 return -ENOMEM;
934 932
935 spin_lock_irq(&dev->event_lock); 933 spin_lock_irq(&dev->event_lock);
936 spin_lock(&client->buffer_lock); 934 spin_lock(&client->buffer_lock);
937 935
938 memcpy(mem, bits, len); 936 bitmap_copy(mem, bits, maxbit);
939 937
940 spin_unlock(&dev->event_lock); 938 spin_unlock(&dev->event_lock);
941 939
@@ -947,7 +945,7 @@ static int evdev_handle_get_val(struct evdev_client *client,
947 if (ret < 0) 945 if (ret < 0)
948 evdev_queue_syn_dropped(client); 946 evdev_queue_syn_dropped(client);
949 947
950 kfree(mem); 948 bitmap_free(mem);
951 949
952 return ret; 950 return ret;
953} 951}
@@ -1003,13 +1001,13 @@ static int evdev_set_mask(struct evdev_client *client,
1003 if (!cnt) 1001 if (!cnt)
1004 return 0; 1002 return 0;
1005 1003
1006 mask = kcalloc(sizeof(unsigned long), BITS_TO_LONGS(cnt), GFP_KERNEL); 1004 mask = bitmap_zalloc(cnt, GFP_KERNEL);
1007 if (!mask) 1005 if (!mask)
1008 return -ENOMEM; 1006 return -ENOMEM;
1009 1007
1010 error = bits_from_user(mask, cnt - 1, codes_size, codes, compat); 1008 error = bits_from_user(mask, cnt - 1, codes_size, codes, compat);
1011 if (error < 0) { 1009 if (error < 0) {
1012 kfree(mask); 1010 bitmap_free(mask);
1013 return error; 1011 return error;
1014 } 1012 }
1015 1013
@@ -1018,7 +1016,7 @@ static int evdev_set_mask(struct evdev_client *client,
1018 client->evmasks[type] = mask; 1016 client->evmasks[type] = mask;
1019 spin_unlock_irqrestore(&client->buffer_lock, flags); 1017 spin_unlock_irqrestore(&client->buffer_lock, flags);
1020 1018
1021 kfree(oldmask); 1019 bitmap_free(oldmask);
1022 1020
1023 return 0; 1021 return 0;
1024} 1022}