diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-05-21 13:56:35 +0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-05-21 13:56:35 +0400 |
commit | b84293b23efd8c98416624866389854fd5dc0020 (patch) | |
tree | f18d7f6c6f46c09306c88e5ebc7ad2d72c3f4d21 /drivers/char | |
parent | 026d68be45a217f65f1617d08271f6838bfc07d7 (diff) | |
parent | f9c6d4987b23e0a514464bae6771933a48e4cd01 (diff) | |
download | linux-b84293b23efd8c98416624866389854fd5dc0020.tar.xz |
Merge tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random
Pull /dev/random fix from Ted Ts'o:
"This fixes a BUG_ON-causing regression that was introduced during the
last merge window"
* tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random:
random: fix BUG_ON caused by accounting simplification
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/random.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 6b75713d953a..102c50d38902 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -995,8 +995,11 @@ retry: ibytes = min_t(size_t, ibytes, have_bytes - reserved); if (ibytes < min) ibytes = 0; - entropy_count = max_t(int, 0, - entropy_count - (ibytes << (ENTROPY_SHIFT + 3))); + if (have_bytes >= ibytes + reserved) + entropy_count -= ibytes << (ENTROPY_SHIFT + 3); + else + entropy_count = reserved << (ENTROPY_SHIFT + 3); + if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) goto retry; |