summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-05-21 18:56:35 +0900
committerLinus Torvalds <torvalds@linux-foundation.org>2014-05-21 18:56:35 +0900
commitb84293b23efd8c98416624866389854fd5dc0020 (patch)
treef18d7f6c6f46c09306c88e5ebc7ad2d72c3f4d21 /drivers/char
parent026d68be45a217f65f1617d08271f6838bfc07d7 (diff)
parentf9c6d4987b23e0a514464bae6771933a48e4cd01 (diff)
downloadop-kernel-dev-b84293b23efd8c98416624866389854fd5dc0020.zip
op-kernel-dev-b84293b23efd8c98416624866389854fd5dc0020.tar.gz
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
Diffstat (limited to 'drivers/char')
-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 6b75713..102c50d 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;
OpenPOWER on IntegriCloud