Skip to content

Commit 230b4d8

Browse files
GseoCspasdeloup
authored andcommitted
fix(st-crypto): do not read RNG data if it's not ready
Having RNG_SR_DRDY bit in RNG_SR register does not mean that there are 4 RNG words ready to be read. Add a check on RNG_SR_DRDY between each word reading. Signed-off-by: Gatien Chevallier <gatien.chevallier@foss.st.com> Change-Id: I46af7ca6c0ddbe19540b248365a5016b15b9a707 Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/tf-a/+/308887 Tested-by: Gatien CHEVALLIER <gatien.chevallier@st.com> Reviewed-by: Gatien CHEVALLIER <gatien.chevallier@st.com> Reviewed-by: Yann GAUTIER <yann.gautier@foss.st.com> ACI: CITOOLS <MDG-smet-aci-reviews@list.st.com> ACI: CIBUILD <MDG-smet-aci-builds@list.st.com> Domain-Review: Lionel DEBIEVE <lionel.debieve@foss.st.com>
1 parent 567c3fd commit 230b4d8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/st/crypto/stm32_rng.c

+4
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ int stm32_rng_read(uint8_t *out, uint32_t size)
187187

188188
count = 4U;
189189
while (len != 0U) {
190+
if ((mmio_read_32(stm32_rng.base + RNG_SR) & RNG_SR_DRDY) == 0U) {
191+
break;
192+
}
193+
190194
data32 = mmio_read_32(stm32_rng.base + RNG_DR);
191195
count--;
192196

0 commit comments

Comments
 (0)