[PATCH 1/8] cmd: rng: fix error handling for dm_rng_read()
Jamie Gibbons
jamie.gibbons at microchip.com
Thu Jun 25 14:23:18 CEST 2026
The rng command treated any non-zero return value from dm_rng_read() as
an error, even though the API returns the number of bytes read on
success.
Update the error handling to only report a failure when dm_rng_read()
returns a negative error code, or when a short read occurs.
This fixes false "Reading RNG failed" messages when RNG drivers
successfully return data.
Signed-off-by: Jamie Gibbons <jamie.gibbons at microchip.com>
---
cmd/rng.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/rng.c b/cmd/rng.c
index 4d91094a8ec..18c0b6c9ca1 100644
--- a/cmd/rng.c
+++ b/cmd/rng.c
@@ -62,7 +62,7 @@ static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
n = min(n, sizeof(buf));
err = dm_rng_read(dev, buf, n);
- if (err) {
+ if (err < 0 || err != n) {
puts(err == -EINTR ? "Abort\n" : "Reading RNG failed\n");
ret = CMD_RET_FAILURE;
} else {
--
2.43.0
More information about the U-Boot
mailing list