From: Theodore Ts'o Date: Wed, 11 Jun 2014 03:18:16 +0000 (-0400) Subject: random: only update the last_pulled time if we actually transferred entropy X-Git-Tag: v5.15~17435^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cff850312cc7c0e0b9fe8b573687812dea232031;p=platform%2Fkernel%2Flinux-starfive.git random: only update the last_pulled time if we actually transferred entropy In xfer_secondary_pull(), check to make sure we need to pull from the secondary pool before checking and potentially updating the last_pulled time. Signed-off-by: Theodore Ts'o Cc: George Spelvin --- diff --git a/drivers/char/random.c b/drivers/char/random.c index bc0de22..364a800 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -920,6 +920,11 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf, static void _xfer_secondary_pool(struct entropy_store *r, size_t nbytes); static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes) { + if (!r->pull || + r->entropy_count >= (nbytes << (ENTROPY_SHIFT + 3)) || + r->entropy_count > r->poolinfo->poolfracbits) + return; + if (r->limit == 0 && random_min_urandom_seed) { unsigned long now = jiffies; @@ -928,10 +933,8 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes) return; r->last_pulled = now; } - if (r->pull && - r->entropy_count < (nbytes << (ENTROPY_SHIFT + 3)) && - r->entropy_count < r->poolinfo->poolfracbits) - _xfer_secondary_pool(r, nbytes); + + _xfer_secondary_pool(r, nbytes); } static void _xfer_secondary_pool(struct entropy_store *r, size_t nbytes)