[COMMON] hw_random: make khwrngd freezable
authorKeunyoung Park <keun0.park@samsung.com>
Mon, 29 Jan 2018 04:24:09 +0000 (13:24 +0900)
committerJunho Choi <junhosj.choi@samsung.com>
Thu, 24 May 2018 00:02:13 +0000 (09:02 +0900)
Change-Id: I8bc0b1561dc8b3d36fec860b0b969129326c334d
Signed-off-by: Keunyoung Park <keun0.park@samsung.com>
drivers/char/hw_random/core.c
drivers/char/random.c

index 9701ac7d8b4712cb15337eac68da7a082e202cf6..2b512ca91f8136afcdbff820f4bc210d31dde616 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
+#include <linux/freezer.h>
 
 #define RNG_MODULE_NAME                "hw_random"
 
@@ -395,6 +396,8 @@ static int hwrng_fillfn(void *unused)
 {
        long rc;
 
+       set_freezable();
+
        while (!kthread_should_stop()) {
                struct hwrng *rng;
 
index ea0115cf5fc0d01faa9b20fa2f1c8dd690a9ab80..5c3f1110d08f38c226fd10b30b3c9949f681878d 100644 (file)
 #include <linux/syscalls.h>
 #include <linux/completion.h>
 #include <linux/uuid.h>
+#include <linux/freezer.h>
 #include <crypto/chacha20.h>
 
 #include <asm/processor.h>
@@ -1632,7 +1633,7 @@ void get_random_bytes_arch(void *buf, int nbytes)
 
                if (!arch_get_random_long(&v))
                        break;
-               
+
                memcpy(p, &v, chunk);
                p += chunk;
                nbytes -= chunk;
@@ -2223,7 +2224,7 @@ void add_hwgenerator_randomness(const char *buffer, size_t count,
         * We'll be woken up again once below random_write_wakeup_thresh,
         * or when the calling thread is about to terminate.
         */
-       wait_event_interruptible(random_write_wait, kthread_should_stop() ||
+       wait_event_freezable(random_write_wait, kthread_should_stop() ||
                        ENTROPY_BITS(&input_pool) <= random_write_wakeup_bits);
        mix_pool_bytes(poolp, buffer, count);
        credit_entropy_bits(poolp, entropy);