From: Jamie Gibbons <jamie.gibbons@microchip.com>
To: <u-boot@lists.denx.de>
Cc: Conor Dooley <conor.dooley@microchip.com>,
Valentina Fernandez Alanis
<valentina.fernandezalanis@microchip.com>,
Tom Rini <trini@konsulko.com>,
Marek Vasut <marek.vasut+renesas@mailbox.org>,
Leo Yu-Chi Liang <ycliang@andestech.com>,
Sughosh Ganu <sughosh.ganu@arm.com>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
Martin Herren <sputnik@on-the-web.ch>,
Michal Simek <michal.simek@amd.com>,
Adriana Nicolae <adriana@arista.com>,
Sam Protsenko <semen.protsenko@linaro.org>,
<jamie.gibbons@microchip.com>
Subject: [PATCH 1/8] cmd: rng: fix error handling for dm_rng_read()
Date: Thu, 25 Jun 2026 13:23:18 +0100 [thread overview]
Message-ID: <20260625122325.834568-2-jamie.gibbons@microchip.com> (raw)
In-Reply-To: <20260625122325.834568-1-jamie.gibbons@microchip.com>
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@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
next prev parent reply other threads:[~2026-06-25 13:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 12:23 [PATCH 0/8] MPFS: add hardware RNG support and fix RNG consumers Jamie Gibbons
2026-06-25 12:23 ` Jamie Gibbons [this message]
2026-06-25 14:38 ` [PATCH 1/8] cmd: rng: fix error handling for dm_rng_read() Simon Glass
2026-06-25 12:23 ` [PATCH 2/8] misc: mpfs_syscontroller: add mailbox RX helper for service responses Jamie Gibbons
2026-07-01 9:45 ` Conor Dooley
2026-06-25 12:23 ` [PATCH 3/8] misc: mpfs_syscontroller: bind RNG sub-device Jamie Gibbons
2026-07-01 9:52 ` Conor Dooley
2026-06-25 12:23 ` [PATCH 4/8] rng: add Microchip PolarFire SoC hardware RNG driver Jamie Gibbons
2026-07-01 9:55 ` Conor Dooley
2026-06-25 12:23 ` [PATCH 5/8] configs: microchip_mpfs_generic: enable MPFS RNG support Jamie Gibbons
2026-07-01 10:04 ` Conor Dooley
2026-06-25 12:23 ` [PATCH 6/8] mailbox: mpfs-mbox: replace unbounded BUSY polling with bounded waits Jamie Gibbons
2026-07-01 10:05 ` Conor Dooley
2026-06-25 12:23 ` [PATCH 7/8] mailbox: mpfs: add bounded wait for BUSY to clear before sending request Jamie Gibbons
2026-07-01 10:06 ` Conor Dooley
2026-06-25 12:23 ` [PATCH 8/8] boot: fdt: downgrade KASLR RNG failure to warning Jamie Gibbons
2026-06-25 14:38 ` Simon Glass
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=20260625122325.834568-2-jamie.gibbons@microchip.com \
--to=jamie.gibbons@microchip.com \
--cc=adriana@arista.com \
--cc=conor.dooley@microchip.com \
--cc=marek.vasut+renesas@mailbox.org \
--cc=michal.simek@amd.com \
--cc=semen.protsenko@linaro.org \
--cc=sputnik@on-the-web.ch \
--cc=sughosh.ganu@arm.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=valentina.fernandezalanis@microchip.com \
--cc=xypron.glpk@gmx.de \
--cc=ycliang@andestech.com \
/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