Skip to content

Commit

Permalink
[S390] hw_random: allow rng_dev_read() to return hardware errors.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ralph Wuerthner authored and Heiko Carstens committed Apr 17, 2008
1 parent c10fde0 commit 893f112
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/char/hw_random/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 893f112

Please sign in to comment.