lib: uuid: fix the test on RNG device presence
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). [backport of commit70a9f4d25b("lib: uuid: fix the test on RNG device presence")] Fixes:92fdad28cf("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> Change-Id: I98a420a5666428a3c4737db51d3f9c31d64c66b5
This commit is contained in:
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user