diff options
-rw-r--r-- | drivers/char/random.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 2c532a6b0a21..9675821b4b5a 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -984,14 +984,10 @@ retry: | |||
984 | ibytes = 0; | 984 | ibytes = 0; |
985 | } else { | 985 | } else { |
986 | /* If limited, never pull more than available */ | 986 | /* If limited, never pull more than available */ |
987 | if (r->limit && ibytes + reserved >= have_bytes) | 987 | if (r->limit) |
988 | ibytes = have_bytes - reserved; | 988 | ibytes = min_t(size_t, ibytes, have_bytes - reserved); |
989 | 989 | entropy_count = max_t(int, 0, | |
990 | if (have_bytes >= ibytes + reserved) | 990 | entropy_count - (ibytes << (ENTROPY_SHIFT + 3))); |
991 | entropy_count -= ibytes << (ENTROPY_SHIFT + 3); | ||
992 | else | ||
993 | entropy_count = reserved << (ENTROPY_SHIFT + 3); | ||
994 | |||
995 | if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) | 991 | if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) |
996 | goto retry; | 992 | goto retry; |
997 | 993 | ||