Re: [PATCH 2/4] crypto: qcom-rng - Allow zero as a random number

From: Konrad Dybcio

Date: Mon Jun 08 2026 - 03:57:40 EST


On 5/30/26 4:03 AM, Eric Biggers wrote:
> Zero is a valid random number and needs to be allowed. Otherwise the
> output is distinguishable from random.
>
> Fixes: f29cd5bb64c2 ("crypto: qcom-rng - Add hw_random interface support")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
> ---
> drivers/crypto/qcom-rng.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c
> index f31a7fe07ba7..b7f3b9695dac 100644
> --- a/drivers/crypto/qcom-rng.c
> +++ b/drivers/crypto/qcom-rng.c
> @@ -63,13 +63,10 @@ static int qcom_rng_read(struct qcom_rng *rng, u8 *data, unsigned int max)
> 200, 10000);
> if (ret)
> return ret;
>
> val = readl_relaxed(rng->base + PRNG_DATA_OUT);
> - if (!val)
> - return -EINVAL;
> -

nit: in case you respin, please keep the \n between the read and the
following checks

Reviewed-by: Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx>

Konrad

> if ((max - currsize) >= WORD_SZ) {
> memcpy(data, &val, WORD_SZ);
> data += WORD_SZ;
> currsize += WORD_SZ;
> } else {