Commit b84293b2 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 026d68be f9c6d498
...@@ -995,8 +995,11 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, ...@@ -995,8 +995,11 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
ibytes = min_t(size_t, ibytes, have_bytes - reserved); ibytes = min_t(size_t, ibytes, have_bytes - reserved);
if (ibytes < min) if (ibytes < min)
ibytes = 0; ibytes = 0;
entropy_count = max_t(int, 0, if (have_bytes >= ibytes + reserved)
entropy_count - (ibytes << (ENTROPY_SHIFT + 3))); entropy_count -= ibytes << (ENTROPY_SHIFT + 3);
else
entropy_count = reserved << (ENTROPY_SHIFT + 3);
if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
goto retry; goto retry;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment