Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 109426
b: refs/heads/master
c: 8b76f46
h: refs/heads/master
v: v3
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Sep 3, 2008
1 parent bb1d7f4 commit 101de44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9d3593574702ae1899e23a1535da1ac71f928042
refs/heads/master: 8b76f46a2db29407fed66cf4aca19d61b3dcb3e1
19 changes: 10 additions & 9 deletions trunk/drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ struct entropy_store {
/* read-write data: */
spinlock_t lock;
unsigned add_ptr;
int entropy_count;
int entropy_count; /* Must at no time exceed ->POOLBITS! */
int input_rotate;
};

Expand Down Expand Up @@ -520,27 +520,28 @@ static void mix_pool_bytes(struct entropy_store *r, const void *in, int bytes)
static void credit_entropy_bits(struct entropy_store *r, int nbits)
{
unsigned long flags;
int entropy_count;

if (!nbits)
return;

spin_lock_irqsave(&r->lock, flags);

DEBUG_ENT("added %d entropy credits to %s\n", nbits, r->name);
r->entropy_count += nbits;
if (r->entropy_count < 0) {
entropy_count = r->entropy_count;
entropy_count += nbits;
if (entropy_count < 0) {
DEBUG_ENT("negative entropy/overflow\n");
r->entropy_count = 0;
} else if (r->entropy_count > r->poolinfo->POOLBITS)
r->entropy_count = r->poolinfo->POOLBITS;
entropy_count = 0;
} else if (entropy_count > r->poolinfo->POOLBITS)
entropy_count = r->poolinfo->POOLBITS;
r->entropy_count = entropy_count;

/* should we wake readers? */
if (r == &input_pool &&
r->entropy_count >= random_read_wakeup_thresh) {
if (r == &input_pool && entropy_count >= random_read_wakeup_thresh) {
wake_up_interruptible(&random_read_wait);
kill_fasync(&fasync, SIGIO, POLL_IN);
}

spin_unlock_irqrestore(&r->lock, flags);
}

Expand Down

0 comments on commit 101de44

Please sign in to comment.