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: Vinicius Costa Gomes <[email protected]>
Reviewed-by: David Herrmann <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
This commit is contained in:
Vinicius Costa Gomes 2012-07-14 18:59:25 -03:00 • committed by Jiri Kosina
commit adefb69b1b

View file

@ -465,7 +465,7 @@ try_again:
goto try_again;
} else {
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;
} else {
kfree(uhid->outq[uhid->tail]);