Skip to contentSkip to conversation

autoboot: Add check for result of malloc_cache_aligned()

PATCH In review Maks Mishin 2 participants 2 messages Feb 29, 2024 – Mar 7, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 autoboot: Add check for result of malloc_cache_aligned()

Return value of a function 'malloc_cache_aligned' is dereferenced at autoboot.c:207 without checking for NULL, but it is usually checked for this function.

Found by RASU JSC.

---
 common/autoboot.c | 3 +++
 1 file changed, 3 insertions(+)
common/autoboot.c +3 -0
index 5d331991c1..6f0aeae6bf 100644
@@ -167,6 +167,9 @@ static int passwd_abort_sha256(uint64_t etime)
 		sha_env_str = AUTOBOOT_STOP_STR_SHA256;
 
 	presskey = malloc_cache_aligned(DELAY_STOP_STR_MAX_LENGTH);
+	if (!presskey)
+		return -ENOMEM;
+
 	c = strstr(sha_env_str, ":");
 	if (c && (c - sha_env_str < DELAY_STOP_STR_MAX_LENGTH)) {
 		/* preload presskey with salt */
Signature · 1 line
2.30.2
#1 lore raw
Quoted 7 lines · Maks Mishin

Return value of a function 'malloc_cache_aligned' is dereferenced at autoboot.c:207 without checking for NULL, but it is usually checked for this function.

Found by RASU JSC.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom