On Fri, 22 Oct 2021 at 09:05, Patrick Delaunay <patrick.delau...@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 <mbrug...@suse.com> > CC: Torsten Duwe <d...@suse.de> > Signed-off-by: Patrick Delaunay <patrick.delau...@foss.st.com> > --- > > lib/uuid.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass <s...@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 >