aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hidraw.c
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2009-10-12 05:25:56 -0400
committerJiri Kosina <jkosina@suse.cz>2009-10-12 05:25:56 -0400
commitb0e14951ee0f6c29abc64b92ec7075a159ede37c (patch)
treeaa10393c1f54a2342fbd4d3624d6e68de376cd8d /drivers/hid/hidraw.c
parentff9b00a226ccea66e6ce70e9083c42f5b6001f73 (diff)
HID: fix possible deadlock in hidraw_read
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>
Diffstat (limited to 'drivers/hid/hidraw.c')
-rw-r--r--drivers/hid/hidraw.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 0c6639ea03dd..b079a9c59958 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -47,10 +47,9 @@ static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count,
47 char *report; 47 char *report;
48 DECLARE_WAITQUEUE(wait, current); 48 DECLARE_WAITQUEUE(wait, current);
49 49
50 while (ret == 0) { 50 mutex_lock(&list->read_mutex);
51
52 mutex_lock(&list->read_mutex);
53 51
52 while (ret == 0) {
54 if (list->head == list->tail) { 53 if (list->head == list->tail) {
55 add_wait_queue(&list->hidraw->wait, &wait); 54 add_wait_queue(&list->hidraw->wait, &wait);
56 set_current_state(TASK_INTERRUPTIBLE); 55 set_current_state(TASK_INTERRUPTIBLE);