From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Om Prakash Singh <quic_omprsing@quicinc.com>,
Bjorn Andersson <quic_bjorande@quicinc.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
linux-arm-msm@vger.kernel.org,
Olivia Mackall <olivia@selenic.com>,
Eric Biggers <ebiggers@kernel.org>,
stable@vger.kernel.org
Subject: [PATCH 2/4] crypto: qcom-rng - Allow zero as a random number
Date: Fri, 29 May 2026 19:03:30 -0700 [thread overview]
Message-ID: <20260530020332.143058-3-ebiggers@kernel.org> (raw)
In-Reply-To: <20260530020332.143058-1-ebiggers@kernel.org>
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@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
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;
-
if ((max - currsize) >= WORD_SZ) {
memcpy(data, &val, WORD_SZ);
data += WORD_SZ;
currsize += WORD_SZ;
} else {
--
2.54.0
next prev parent reply other threads:[~2026-05-30 2:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-30 2:03 [PATCH 0/4] qcom-rng fixes and cleanups Eric Biggers
2026-05-30 2:03 ` [PATCH 1/4] crypto: qcom-rng - Enable clock in hwrng case Eric Biggers
2026-05-30 2:03 ` Eric Biggers [this message]
2026-05-30 2:03 ` [PATCH 3/4] crypto: qcom-rng - Remove crypto_rng interface Eric Biggers
2026-05-30 2:03 ` [PATCH 4/4] hwrng: qcom - Move qcom-rng.c into drivers/char/hw_random/ Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260530020332.143058-3-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=olivia@selenic.com \
--cc=quic_bjorande@quicinc.com \
--cc=quic_omprsing@quicinc.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox