Skip to content

Commit

Permalink
HID: fix possible deadlock in hidraw_read
Browse files Browse the repository at this point in the history
If the loop in hidraw_read() loops more than once, then we might
end up trying to acquire already locked mutex, casuing a deadlock.

Reported-by: iceberg <iceberg@ispras.ru>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Jiri Kosina committed Oct 12, 2009
1 parent ff9b00a commit b0e1495
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/hid/hidraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count,
char *report;
DECLARE_WAITQUEUE(wait, current);

while (ret == 0) {

mutex_lock(&list->read_mutex);
mutex_lock(&list->read_mutex);

while (ret == 0) {
if (list->head == list->tail) {
add_wait_queue(&list->hidraw->wait, &wait);
set_current_state(TASK_INTERRUPTIBLE);
Expand Down

0 comments on commit b0e1495

Please sign in to comment.