]> err.no Git - linux-2.6/commitdiff
[S390] hw_random: allow rng_dev_read() to return hardware errors.
authorRalph Wuerthner <rwuerthn@de.ibm.com>
Thu, 17 Apr 2008 05:46:14 +0000 (07:46 +0200)
committerHeiko Carstens <heiko.carstens@de.ibm.com>
Thu, 17 Apr 2008 05:47:02 +0000 (07:47 +0200)
The api for hardware random number generators is currently limited to
devices that never fail. If the hardware is registered as a source for
random numbers it has to work. This prevents the use of i/o based
random number devices where the i/o might fail.

Add a check for errors after the read from a hardware random number device.

This patch is required to support large random numbers retrieved
from the CEX2C cards on System z.

Signed-off-by: Ralph Wuerthner <rwuerthn@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
drivers/char/hw_random/core.c

index 84cdf9025737722fe4341974cf3bce90d268bc3f..349b6edc5794401ab9a4388707a93f9570aeaa7c 100644 (file)
@@ -116,6 +116,10 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf,
                err = -EAGAIN;
                if (!bytes_read && (filp->f_flags & O_NONBLOCK))
                        goto out;
+               if (bytes_read < 0) {
+                       err = bytes_read;
+                       goto out;
+               }
 
                err = -EFAULT;
                while (bytes_read && size) {