Skip to content

Commit f95dabe

Browse files
mpeozbenh
authored andcommitted
hwrng: Return errors to upper levels in pseries-rng.c
We don't expect to get errors from the hypervisor when reading the rng, but if we do we should pass the error up to the hwrng driver. Otherwise the hwrng driver will continue calling us forever. Signed-off-by: Michael Ellerman <[email protected]> Signed-off-by: Benjamin Herrenschmidt <[email protected]>
1 parent 41b93b2 commit f95dabe

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/char/hw_random/pseries-rng.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1818
*/
1919

20+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21+
22+
#include <linux/kernel.h>
2023
#include <linux/module.h>
2124
#include <linux/hw_random.h>
2225
#include <asm/vio.h>
@@ -25,10 +28,15 @@
2528

2629
static int pseries_rng_data_read(struct hwrng *rng, u32 *data)
2730
{
28-
if (plpar_hcall(H_RANDOM, (unsigned long *)data) != H_SUCCESS) {
29-
printk(KERN_ERR "pseries rng hcall error\n");
30-
return 0;
31+
int rc;
32+
33+
rc = plpar_hcall(H_RANDOM, (unsigned long *)data);
34+
if (rc != H_SUCCESS) {
35+
pr_err_ratelimited("H_RANDOM call failed %d\n", rc);
36+
return -EIO;
3137
}
38+
39+
/* The hypervisor interface returns 64 bits */
3240
return 8;
3341
}
3442

0 commit comments

Comments
 (0)