From b560c704d66edf30c32c2a588bc1d177750bb418 Mon Sep 17 00:00:00 2001 From: Philippe Reynes Date: Fri, 15 Oct 2021 11:28:47 +0200 Subject: lib: rsa: rsa-verify: also check that padding is not NULL This commit adds a check on the padding in the function rsa_verify_key to avoid using a NULL pointer. Signed-off-by: Philippe Reynes Reviewed-by: Simon Glass --- lib/rsa/rsa-verify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 600c93ab810..83f7564101c 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -340,7 +340,7 @@ static int rsa_verify_key(struct image_sign_info *info, struct padding_algo *padding = info->padding; int hash_len; - if (!prop || !sig || !hash || !checksum) + if (!prop || !sig || !hash || !checksum || !padding) return -EIO; if (sig_len != (prop->num_bits / 8)) { -- cgit v1.2.3 From 70a9f4d25b4383c22b74a6a4354927644392debb Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Fri, 22 Oct 2021 17:05:47 +0200 Subject: 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). Fixes: 92fdad28cfdf ("lib: uuid: use RNG device if present") CC: Matthias Brugger CC: Torsten Duwe Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass --- lib/uuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/uuid.c b/lib/uuid.c index 67267c66a3c..e4703dce2b5 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; -- cgit v1.2.3