random: entropy: Always check device is ready

Use a proper branch instead of an assert to check if the device
is ready. It can potentialy lead to improper random
value that can compromise security.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
This commit is contained in:
Flavio Ceolin
2026-01-16 09:29:35 -08:00
committed by Anas Nashif
parent 213b1605d8
commit cc1391b5f7

View File

@@ -17,8 +17,9 @@ static int rand_get(uint8_t *dst, size_t outlen, bool csrand)
uint32_t random_num;
int ret;
__ASSERT(device_is_ready(entropy_dev), "Entropy device %s not ready",
entropy_dev->name);
if (!device_is_ready(entropy_dev)) {
return -ENODEV;
}
ret = entropy_get_entropy(entropy_dev, dst, outlen);