Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[sfrench/cifs-2.6.git] / drivers / input / evdev.c
index f040d8881ff2a2db34d56a816026e69524239f3b..d1e25aba8212ad3c19f66bbd704835406e78d065 100644 (file)
@@ -503,14 +503,13 @@ static int evdev_open(struct inode *inode, struct file *file)
 {
        struct evdev *evdev = container_of(inode->i_cdev, struct evdev, cdev);
        unsigned int bufsize = evdev_compute_buffer_size(evdev->handle.dev);
 {
        struct evdev *evdev = container_of(inode->i_cdev, struct evdev, cdev);
        unsigned int bufsize = evdev_compute_buffer_size(evdev->handle.dev);
-       unsigned int size = sizeof(struct evdev_client) +
-                                       bufsize * sizeof(struct input_event);
        struct evdev_client *client;
        int error;
 
        struct evdev_client *client;
        int error;
 
-       client = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
+       client = kzalloc(struct_size(client, buffer, bufsize),
+                        GFP_KERNEL | __GFP_NOWARN);
        if (!client)
        if (!client)
-               client = vzalloc(size);
+               client = vzalloc(struct_size(client, buffer, bufsize));
        if (!client)
                return -ENOMEM;
 
        if (!client)
                return -ENOMEM;