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 <[email protected]> --- 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

