|
@@ -984,14 +984,10 @@ retry:
|
|
ibytes = 0;
|
|
ibytes = 0;
|
|
} else {
|
|
} else {
|
|
/* If limited, never pull more than available */
|
|
/* If limited, never pull more than available */
|
|
- if (r->limit && ibytes + reserved >= have_bytes)
|
|
|
|
- ibytes = have_bytes - reserved;
|
|
|
|
-
|
|
|
|
- if (have_bytes >= ibytes + reserved)
|
|
|
|
- entropy_count -= ibytes << (ENTROPY_SHIFT + 3);
|
|
|
|
- else
|
|
|
|
- entropy_count = reserved << (ENTROPY_SHIFT + 3);
|
|
|
|
-
|
|
|
|
|
|
+ if (r->limit)
|
|
|
|
+ ibytes = min_t(size_t, ibytes, have_bytes - reserved);
|
|
|
|
+ entropy_count = max_t(int, 0,
|
|
|
|
+ entropy_count - (ibytes << (ENTROPY_SHIFT + 3)));
|
|
if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
|
|
if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
|
|
goto retry;
|
|
goto retry;
|
|
|
|
|