All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib: uuid: fix the test on RNG device presence
@ 2021-10-22 15:05 Patrick Delaunay
  2021-10-24 19:54 ` Simon Glass
  2021-10-26 22:41 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Patrick Delaunay @ 2021-10-22 15:05 UTC (permalink / raw)
  To: u-boot
  Cc: Patrick Delaunay, Matthias Brugger, Torsten Duwe,
	Rasmus Villemoes, Simon Glass, U-Boot STM32

Correct the test on RNG device presence,when ret is equal to 0,
before to call dm_rng_read function.

Without this patch the RNG device is not used when present (when ret == 0)
or a data abort occurs in dm_rng_read when CONFIG_DM_RNG is activated but
the RNG device is not present in device tree (ret != 0 and devp = NULL).

Fixes: 92fdad28cfdf ("lib: uuid: use RNG device if present")
CC: Matthias Brugger <mbrugger@suse.com>
CC: Torsten Duwe <duwe@suse.de>
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 lib/uuid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/uuid.c b/lib/uuid.c
index 67267c66a3..e4703dce2b 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -257,7 +257,7 @@ void gen_rand_uuid(unsigned char *uuid_bin)
 
 	if (IS_ENABLED(CONFIG_DM_RNG)) {
 		ret = uclass_get_device(UCLASS_RNG, 0, &devp);
-		if (ret) {
+		if (!ret) {
 			ret = dm_rng_read(devp, &randv, sizeof(randv));
 			if (ret < 0)
 				randv = 0;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] lib: uuid: fix the test on RNG device presence
  2021-10-22 15:05 [PATCH] lib: uuid: fix the test on RNG device presence Patrick Delaunay
@ 2021-10-24 19:54 ` Simon Glass
  2021-10-26 22:41 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2021-10-24 19:54 UTC (permalink / raw)
  To: Patrick Delaunay
  Cc: U-Boot Mailing List, Matthias Brugger, Torsten Duwe,
	Rasmus Villemoes, U-Boot STM32

On Fri, 22 Oct 2021 at 09:05, Patrick Delaunay
<patrick.delaunay@foss.st.com> wrote:
>
> Correct the test on RNG device presence,when ret is equal to 0,
> before to call dm_rng_read function.
>
> Without this patch the RNG device is not used when present (when ret == 0)
> or a data abort occurs in dm_rng_read when CONFIG_DM_RNG is activated but
> the RNG device is not present in device tree (ret != 0 and devp = NULL).
>
> Fixes: 92fdad28cfdf ("lib: uuid: use RNG device if present")
> CC: Matthias Brugger <mbrugger@suse.com>
> CC: Torsten Duwe <duwe@suse.de>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
>
>  lib/uuid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

OMG


>
> diff --git a/lib/uuid.c b/lib/uuid.c
> index 67267c66a3..e4703dce2b 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -257,7 +257,7 @@ void gen_rand_uuid(unsigned char *uuid_bin)
>
>         if (IS_ENABLED(CONFIG_DM_RNG)) {
>                 ret = uclass_get_device(UCLASS_RNG, 0, &devp);
> -               if (ret) {
> +               if (!ret) {
>                         ret = dm_rng_read(devp, &randv, sizeof(randv));
>                         if (ret < 0)
>                                 randv = 0;
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] lib: uuid: fix the test on RNG device presence
  2021-10-22 15:05 [PATCH] lib: uuid: fix the test on RNG device presence Patrick Delaunay
  2021-10-24 19:54 ` Simon Glass
@ 2021-10-26 22:41 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2021-10-26 22:41 UTC (permalink / raw)
  To: Patrick Delaunay
  Cc: u-boot, Matthias Brugger, Torsten Duwe, Rasmus Villemoes,
	Simon Glass, U-Boot STM32

[-- Attachment #1: Type: text/plain, Size: 720 bytes --]

On Fri, Oct 22, 2021 at 05:05:47PM +0200, Patrick Delaunay wrote:

> Correct the test on RNG device presence,when ret is equal to 0,
> before to call dm_rng_read function.
> 
> Without this patch the RNG device is not used when present (when ret == 0)
> or a data abort occurs in dm_rng_read when CONFIG_DM_RNG is activated but
> the RNG device is not present in device tree (ret != 0 and devp = NULL).
> 
> Fixes: 92fdad28cfdf ("lib: uuid: use RNG device if present")
> CC: Matthias Brugger <mbrugger@suse.com>
> CC: Torsten Duwe <duwe@suse.de>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-26 22:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22 15:05 [PATCH] lib: uuid: fix the test on RNG device presence Patrick Delaunay
2021-10-24 19:54 ` Simon Glass
2021-10-26 22:41 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.