Commit adefb69b authored by Vinicius Costa Gomes's avatar Vinicius Costa Gomes Committed by Jiri Kosina

HID: uhid: Fix sending events with invalid data

This was detected because events with invalid types were arriving
to userspace.

The code before this patch would only work for the first event in the
queue (when uhid->tail is 0).
Signed-off-by: default avatarVinicius Costa Gomes <vinicius.gomes@openbossa.org>
Reviewed-by: default avatarDavid Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 1a8b294c
...@@ -465,7 +465,7 @@ static ssize_t uhid_char_read(struct file *file, char __user *buffer, ...@@ -465,7 +465,7 @@ static ssize_t uhid_char_read(struct file *file, char __user *buffer,
goto try_again; goto try_again;
} else { } else {
len = min(count, sizeof(**uhid->outq)); len = min(count, sizeof(**uhid->outq));
if (copy_to_user(buffer, &uhid->outq[uhid->tail], len)) { if (copy_to_user(buffer, uhid->outq[uhid->tail], len)) {
ret = -EFAULT; ret = -EFAULT;
} else { } else {
kfree(uhid->outq[uhid->tail]); kfree(uhid->outq[uhid->tail]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment