From: Jiri Kosina Date: Mon, 12 Oct 2009 09:25:56 +0000 (+0200) Subject: HID: fix possible deadlock in hidraw_read X-Git-Tag: v2.6.32-rc5~30^2 X-Git-Url: http://git.cascardo.info/?a=commitdiff_plain;ds=sidebyside;h=b0e14951ee0f6c29abc64b92ec7075a159ede37c;p=cascardo%2Flinux.git 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 Signed-off-by: Jiri Kosina --- 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, 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);