summaryrefslogtreecommitdiff
path: root/drivers/char/random.c
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2014-05-29 13:39:43 -0700
committerOlof Johansson <olof@lixom.net>2014-05-29 13:39:43 -0700
commit8320857b1d168fd17d7cee48bbfd04aaf6797be8 (patch)
tree58b31d3d9514df93974216f190824d73f9816d9f /drivers/char/random.c
parent263c08af44741697202b85e631a964ee85200eb0 (diff)
parent4b660a7f5c8099d88d1a43d8ae138965112592c7 (diff)
Merge tag 'v3.15-rc6' into next/defconfig
Linux 3.15-rc6
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r--drivers/char/random.c7
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;