summaryrefslogtreecommitdiff
path: root/lib/rsa/rsa-verify.c
diff options
context:
space:
mode:
authorPhilippe Reynes <philippe.reynes@softathome.com>2019-03-19 10:55:40 +0100
committerTom Rini <trini@konsulko.com>2019-03-25 11:44:12 -0400
commitb02f2e79c6272d97bf0bd191e6ec8e748a39ad58 (patch)
tree2a4e165c8419497647239939a919bfd9bbee9246 /lib/rsa/rsa-verify.c
parentcfb3e102c4bdf96a41cbd3eeb1d3a9a56c69c46c (diff)
rsa: check that pointer checksum isn't NULL before using it
The pointer checksum were used before checking that it isn't NULL. We move the code that use it after the check. Reported-by: Coverity (CID: 185835) Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/rsa/rsa-verify.c')
-rw-r--r--lib/rsa/rsa-verify.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
index 9734f6d3bd..287fcc4d23 100644
--- a/lib/rsa/rsa-verify.c
+++ b/lib/rsa/rsa-verify.c
@@ -295,7 +295,7 @@ static int rsa_verify_key(struct image_sign_info *info,
#endif
struct checksum_algo *checksum = info->checksum;
struct padding_algo *padding = info->padding;
- int hash_len = checksum->checksum_len;
+ int hash_len;
if (!prop || !sig || !hash || !checksum)
return -EIO;
@@ -315,6 +315,7 @@ static int rsa_verify_key(struct image_sign_info *info,
}
uint8_t buf[sig_len];
+ hash_len = checksum->checksum_len;
#if !defined(USE_HOSTCC)
ret = uclass_get_device(UCLASS_MOD_EXP, 0, &mod_exp_dev);