summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-06-22 12:33:51 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-06-22 12:33:51 -0400
commitef7994fa2aecd8d1fb0d75034caa050ff908d26a (patch)
treeaa7bbe9499256ced149dce70891de5eedf33c283 /drivers/char
parentad8686bc05adc2b8301d749f5958bd904f3a46ee (diff)
parenta497c3ba1d97fc69c1e78e7b96435ba8c2cb42ee (diff)
downloadop-kernel-dev-ef7994fa2aecd8d1fb0d75034caa050ff908d26a.zip
op-kernel-dev-ef7994fa2aecd8d1fb0d75034caa050ff908d26a.tar.gz
Merge 3.16-rc2 into staging-next
We want the staging fixes here as well.
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/random.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 4ad71ef..0a7ac0a 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -980,7 +980,6 @@ static void push_to_pool(struct work_struct *work)
static size_t account(struct entropy_store *r, size_t nbytes, int min,
int reserved)
{
- int have_bytes;
int entropy_count, orig;
size_t ibytes;
@@ -989,17 +988,19 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
/* Can we pull enough? */
retry:
entropy_count = orig = ACCESS_ONCE(r->entropy_count);
- have_bytes = entropy_count >> (ENTROPY_SHIFT + 3);
ibytes = nbytes;
/* If limited, never pull more than available */
- if (r->limit)
- ibytes = min_t(size_t, ibytes, have_bytes - reserved);
+ if (r->limit) {
+ int have_bytes = entropy_count >> (ENTROPY_SHIFT + 3);
+
+ if ((have_bytes -= reserved) < 0)
+ have_bytes = 0;
+ ibytes = min_t(size_t, ibytes, have_bytes);
+ }
if (ibytes < min)
ibytes = 0;
- if (have_bytes >= ibytes + reserved)
- entropy_count -= ibytes << (ENTROPY_SHIFT + 3);
- else
- entropy_count = reserved << (ENTROPY_SHIFT + 3);
+ if ((entropy_count -= ibytes << (ENTROPY_SHIFT + 3)) < 0)
+ entropy_count = 0;
if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
goto retry;
OpenPOWER on IntegriCloud