Commit 042b4b16 authored by James Cowgill's avatar James Cowgill Committed by Herbert Xu
Browse files

hwrng: arm-smccc-trng - fix NO_ENTROPY handling



The SMCCC_RET_TRNG_NO_ENTROPY switch arm is never used because the
NO_ENTROPY return value is negative and negative values are handled
above the switch by immediately returning.

Fix by handling errors using a default arm in the switch.

Fixes: 0888d04b ("hwrng: Add Arm SMCCC TRNG based driver")
Signed-off-by: default avatarJames Cowgill <james.cowgill@blaize.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 882aa652
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -71,8 +71,6 @@ static int smccc_trng_read(struct hwrng *rng, void *data, size_t max, bool wait)
				  MAX_BITS_PER_CALL);

		arm_smccc_1_1_invoke(ARM_SMCCC_TRNG_RND, bits, &res);
		if ((int)res.a0 < 0)
			return (int)res.a0;

		switch ((int)res.a0) {
		case SMCCC_RET_SUCCESS:
@@ -88,6 +86,8 @@ static int smccc_trng_read(struct hwrng *rng, void *data, size_t max, bool wait)
				return copied;
			cond_resched();
			break;
		default:
			return -EIO;
		}
	}