From: Jiri Kosina <jkosina@suse.cz>
To: iceberg <iceberg@ispras.ru>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [BUG] hidraw.c: double mutex_lock
Date: Mon, 12 Oct 2009 11:25:13 +0200 (CEST) [thread overview]
Message-ID: <alpine.LSU.2.00.0910121124110.19284@wotan.suse.de> (raw)
In-Reply-To: <1255353109.13239.0@pamir>
On Mon, 12 Oct 2009, iceberg wrote:
> KERNEL_VERSION: 2.6.31
> DESCRIBE:
> In driver ./drivers/hid/hidraw.c in function hidraw_read may be
> double mutex_lock:
>
> Path:
> 1. line 50: begin first iteration of "while(ret==0)"
> 2. line 52: first call to mutex_lock
> 3. inner loop "while (list->head == list->tail)" does not change state
> of mutex, because mutex_lock immediatelly follows mutex_unlock
> 4. if we go to the second iteration of "while(ret == 0)" in
> line 50 then there are second call to mutex_lock in line 52 (mutex
> aquired twice).
>
> Second iteration of loop "while(ret==0)" is possible if local variable
> ret is not changed at line 94: ret+=len - i.e. len==0;
> Variable len may be zero if hidraw_read is called with count==0 or
> list->buffer[list->tail].len == 0.
Good catch. I will fix that up by moving the mutex_lock() so that it's
locked before the loop is entered.
Thanks,
--
Jiri Kosina
SUSE Labs, Novell Inc.
prev parent reply other threads:[~2009-10-12 9:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-12 13:11 iceberg
2009-10-12 9:25 ` Jiri Kosina [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LSU.2.00.0910121124110.19284@wotan.suse.de \
--to=jkosina@suse.cz \
--cc=iceberg@ispras.ru \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®