summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Moryakov <ant.v.moryakov@gmail.com>2025-02-07 00:55:21 +0300
committerTom Rini <trini@konsulko.com>2025-02-11 08:17:23 -0600
commitbdf056441de30e639d2bc80c32027de3bf28ac4a (patch)
tree1c7f9006b69a858ce383b3a02a1a097fce3c76f9
parent4e18b47c73cdffb1dbd9ea196aeaff20e5030ade (diff)
common: Add NULL checks for malloc_cache_aligned in autoboot.c
- Check return value of malloc_cache_aligned for presskey and sha. - Return -ENOMEM if memory allocation fails. - Free allocated memory in error paths." Triggers found by static analyzer Svace. Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
-rw-r--r--common/autoboot.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/common/autoboot.c b/common/autoboot.c
index 898a57bc92b..0a254498d40 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -186,10 +186,15 @@ static int passwd_abort_sha256(uint64_t etime)
ret = hash_parse_string(algo_name, sha_env_str, sha_env);
if (ret) {
printf("Hash %s not supported!\n", algo_name);
+ free(presskey);
return 0;
}
sha = malloc_cache_aligned(SHA256_SUM_LEN);
+ if (!sha) {
+ free(presskey);
+ return -ENOMEM;
+ }
size = SHA256_SUM_LEN;
/*
* We don't know how long the stop-string is, so we need to