hwrng: core - sleep interruptible in read
[cascardo/linux.git] / drivers / char / hw_random / core.c
index 6f497aa..9203f2d 100644 (file)
@@ -238,7 +238,10 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf,
                        goto out;
                }
 
-               mutex_lock(&reading_mutex);
+               if (mutex_lock_interruptible(&reading_mutex)) {
+                       err = -ERESTARTSYS;
+                       goto out_put;
+               }
                if (!data_avail) {
                        bytes_read = rng_get_data(rng, rng_buffer,
                                rng_buffer_size(),
@@ -288,6 +291,7 @@ out:
 
 out_unlock_reading:
        mutex_unlock(&reading_mutex);
+out_put:
        put_rng(rng);
        goto out;
 }