Commit 96fe2ab8 authored by Johannes Weiner's avatar Johannes Weiner Committed by Jiri Kosina

HID: fix waitqueue usage in hiddev

DECLARE_WAITQUEUE doesn't initialize the wait descriptor's task_list
to 'empty' but to zero.

prepare_to_wait() will not enqueue the descriptor to the waitqueue and
finish_wait() will do list_del_init() on a list head that contains
NULL pointers, which oopses.

This was introduced by 07903407 "HID: hiddev cleanup -- handle all
error conditions properly".

The prior code used an unconditional add_to_waitqueue() which didn't
care about the wait descriptor's list head and enqueued the thing
unconditionally.

The new code uses prepare_to_wait() which DOES check the prior list
state, so use DEFINE_WAIT instead.
Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Cc: Oliver Neukum <oliver@neukum.name>
Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 48e7a3c9
...@@ -323,7 +323,7 @@ static ssize_t hiddev_write(struct file * file, const char __user * buffer, size ...@@ -323,7 +323,7 @@ static ssize_t hiddev_write(struct file * file, const char __user * buffer, size
*/ */
static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos) static ssize_t hiddev_read(struct file * file, char __user * buffer, size_t count, loff_t *ppos)
{ {
DECLARE_WAITQUEUE(wait, current); DEFINE_WAIT(wait);
struct hiddev_list *list = file->private_data; struct hiddev_list *list = file->private_data;
int event_size; int event_size;
int retval; int retval;
......
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