Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <michael@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Michael Ellerman and committed by
Benjamin Herrenschmidt
f95dabef 41b93b23

+11 -3
+11 -3
drivers/char/hw_random/pseries-rng.c
··· 17 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 */ 19 19 20 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 21 + 22 + #include <linux/kernel.h> 20 23 #include <linux/module.h> 21 24 #include <linux/hw_random.h> 22 25 #include <asm/vio.h> ··· 28 25 29 26 static int pseries_rng_data_read(struct hwrng *rng, u32 *data) 30 27 { 31 - if (plpar_hcall(H_RANDOM, (unsigned long *)data) != H_SUCCESS) { 32 - printk(KERN_ERR "pseries rng hcall error\n"); 33 - return 0; 28 + int rc; 29 + 30 + rc = plpar_hcall(H_RANDOM, (unsigned long *)data); 31 + if (rc != H_SUCCESS) { 32 + pr_err_ratelimited("H_RANDOM call failed %d\n", rc); 33 + return -EIO; 34 34 } 35 + 36 + /* The hypervisor interface returns 64 bits */ 35 37 return 8; 36 38 } 37 39