mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-23 22:14:54 +00:00
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>
This commit is contained in:
parent
4e18b47c73
commit
bdf056441d
1 changed files with 5 additions and 0 deletions
|
@ -186,10 +186,15 @@ static int passwd_abort_sha256(uint64_t etime)
|
||||||
ret = hash_parse_string(algo_name, sha_env_str, sha_env);
|
ret = hash_parse_string(algo_name, sha_env_str, sha_env);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("Hash %s not supported!\n", algo_name);
|
printf("Hash %s not supported!\n", algo_name);
|
||||||
|
free(presskey);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sha = malloc_cache_aligned(SHA256_SUM_LEN);
|
sha = malloc_cache_aligned(SHA256_SUM_LEN);
|
||||||
|
if (!sha) {
|
||||||
|
free(presskey);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
size = SHA256_SUM_LEN;
|
size = SHA256_SUM_LEN;
|
||||||
/*
|
/*
|
||||||
* We don't know how long the stop-string is, so we need to
|
* We don't know how long the stop-string is, so we need to
|
||||||
|
|
Loading…
Add table
Reference in a new issue