Skip to content

Commit

Permalink
Merge tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/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
  • Loading branch information
Linus Torvalds committed May 21, 2014
2 parents 026d68b + f9c6d49 commit b84293b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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;

Expand Down

0 comments on commit b84293b

Please sign in to comment.