From: James Lamanna The following is a small patch to return EINVAL when the value given to read() from an event device is not a multiple of sizeof(struct input_event). Prior to this patch read() with a size less than sizeof(struct input_event) would always return 0. This should probably be marked as an error. Signed-off-by: James Lamanna Signed-off-by: Andrew Morton --- 25-akpm/drivers/input/evdev.c | 3 +++ 1 files changed, 3 insertions(+) diff -puN drivers/input/evdev.c~evdev-return-einval-if-read-size-is-not-multiple-of-struct-size drivers/input/evdev.c --- 25/drivers/input/evdev.c~evdev-return-einval-if-read-size-is-not-multiple-of-struct-size Mon Nov 8 16:18:08 2004 +++ 25-akpm/drivers/input/evdev.c Mon Nov 8 16:18:08 2004 @@ -181,6 +181,9 @@ static ssize_t evdev_read(struct file * if (!list->evdev->exist) return -ENODEV; + if (count % sizeof(struct input_event) != 0) + return -EINVAL; + while (list->head != list->tail && retval + sizeof(struct input_event) <= count) { if (copy_to_user(buffer + retval, list->buffer + list->tail, sizeof(struct input_event))) return -EFAULT; _