From: Dan Carpenter <error27@gmail.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Matt Mackall <mpm@selenic.com>, linux-kernel@vger.kernel.org
Subject: Re: double unlock in rng_dev_read()
Date: Thu, 24 Dec 2009 12:51:02 +0200 [thread overview]
Message-ID: <20091224105102.GE23721@bicker> (raw)
In-Reply-To: <20091223152355.GA31379@gondor.apana.org.au>
On Wed, Dec 23, 2009 at 11:23:55PM +0800, Herbert Xu wrote:
> On Wed, Dec 23, 2009 at 04:53:36PM +0200, Dan Carpenter wrote:
> >
> > No no. I mean when size hits zero we are rng_mutex is unlocked.
>
> Good catch! I'll add this patch to the tree. Please take a look
> at it. Thanks!
>
Great.
Acked-by: Dan Carpenter <error27@gmail.com>
regards,
dan carpenter
> commit f5908267b67917b8cbd98b27fd2be9b5f62ec76f
> Author: Herbert Xu <herbert@gondor.apana.org.au>
> Date: Wed Dec 23 23:22:34 2009 +0800
>
> hwrng: core - Fix double unlock in rng_dev_read
>
> When the loop terminates with size == 0 in rng_dev_read we will
> unlock the rng mutex twice.
>
> Reported-by: Dan Carpenter <error27@gmail.com>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>
> diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
> index e989f67..3d9c61e 100644
> --- a/drivers/char/hw_random/core.c
> +++ b/drivers/char/hw_random/core.c
> @@ -158,10 +158,11 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf,
> goto out;
> }
> }
> -out_unlock:
> - mutex_unlock(&rng_mutex);
> out:
> return ret ? : err;
> +out_unlock:
> + mutex_unlock(&rng_mutex);
> + goto out;
> }
>
> --
> Visit Openswan at http://www.openswan.org/
> Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
prev parent reply other threads:[~2009-12-24 10:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-23 13:15 double unlock in rng_dev_read() Dan Carpenter
2009-12-23 14:36 ` Herbert Xu
2009-12-23 14:53 ` Dan Carpenter
2009-12-23 15:23 ` Herbert Xu
2009-12-24 10:51 ` Dan Carpenter [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=20091224105102.GE23721@bicker \
--to=error27@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-kernel@vger.kernel.org \
--cc=mpm@selenic.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.