]> git.baikalelectronics.ru Git - kernel.git/commit
random: don't try to look at entropy_count outside the lock
authorMatt Mackall <mpm@selenic.com>
Tue, 6 Jan 2009 22:42:55 +0000 (14:42 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 6 Jan 2009 23:59:30 +0000 (15:59 -0800)
commit31d8a2b21bb2bfc701dd7c507fe884b38e4d1dc0
tree622c2b4d01d99e6c26a4f0ea554f866151becb2f
parent2f2c8ba70d95704e27494f7b02e38d721cca25f2
random: don't try to look at entropy_count outside the lock

As a non-atomic value, it's only safe to look at entropy_count when the
pool lock is held, so we move the BUG_ON inside the lock for correctness.

Also remove the spurious comment.  It's ok for entropy_count to
temporarily exceed POOLBITS so long as it's left in a consistent state
when the lock is released.

This is a more correct, simple, and idiomatic fix for the bug in
df453ec9699.  I've left the reorderings introduced by that patch in place
as they're harmless, even though they don't properly deal with potential
atomicity issues.

Signed-off-by: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/char/random.c