Gitweb: http://git.kernel.org/linus/ca9fe1588427f246ad4c389b0170b29a432804b6 Commit: ca9fe1588427f246ad4c389b0170b29a432804b6 Parent: 6e32819e12ffbd507eced11a1871700a387d5407 Author: Julia Lawall <julia@diku.dk> AuthorDate: Sun Jun 20 13:24:35 2010 +0200 Committer: Jiri Kosina <jkosina@suse.cz> CommitDate: Mon Jun 21 13:41:54 2010 +0200 HID: eliminate a double lock in debug code The path around the loop ends with the lock held, so the call to mutex_lock is moved before the beginning of the loop. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @locked@ expression E1; position p; @@ read_lock(E1@p,...); @r exists@ expression x <= locked.E1; expression locked.E1; expression E2; identifier lock; position locked.p,p1,p2; @@ *lock@p1 (E1@p,...); ... when != E1 when != \(x = E2\|&x\) *lock@p2 (E1,...); // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Jiri Kosina <jkosina@suse.cz> --- drivers/hid/hid-debug.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c index c940267..850d02a 100644 --- a/drivers/hid/hid-debug.c +++ b/drivers/hid/hid-debug.c @@ -949,8 +949,8 @@ static ssize_t hid_debug_events_read(struct file *file, char __user *buffer, int ret = 0, len; DECLARE_WAITQUEUE(wait, current); + mutex_lock(&list->read_mutex); while (ret == 0) { - mutex_lock(&list->read_mutex); if (list->head == list->tail) { add_wait_queue(&list->hdev->debug_wait, &wait); set_current_state(TASK_INTERRUPTIBLE); -- To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
