]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/random.c
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik...
[linux-2.6-omap-h63xx.git] / drivers / char / random.c
index 0474cac4a84ed882e4bb92d825beb1afcb6db69f..397c714cf2ba78b517a363f0bef2eb674309cb13 100644 (file)
@@ -693,9 +693,14 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
 
        if (r->pull && r->entropy_count < nbytes * 8 &&
            r->entropy_count < r->poolinfo->POOLBITS) {
-               int bytes = max_t(int, random_read_wakeup_thresh / 8,
-                               min_t(int, nbytes, sizeof(tmp)));
+               /* If we're limited, always leave two wakeup worth's BITS */
                int rsvd = r->limit ? 0 : random_read_wakeup_thresh/4;
+               int bytes = nbytes;
+
+               /* pull at least as many as BYTES as wakeup BITS */
+               bytes = max_t(int, bytes, random_read_wakeup_thresh / 8);
+               /* but never more than the buffer size */
+               bytes = min_t(int, bytes, sizeof(tmp));
 
                DEBUG_ENT("going to reseed %s with %d bits "
                          "(%d of %d requested)\n",
@@ -794,7 +799,7 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
 
        buf[0] ^= buf[3];
        buf[1] ^= buf[4];
-       buf[0] ^= rol32(buf[3], 16);
+       buf[2] ^= rol32(buf[2], 16);
        memcpy(out, buf, EXTRACT_SIZE);
        memset(buf, 0, sizeof(buf));
 }