]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
autoboot: Add check for result of malloc_cache_aligned()
authorMaks Mishin <maks.mishinfz@gmail.com>
Thu, 29 Feb 2024 22:32:11 +0000 (01:32 +0300)
committerTom Rini <trini@konsulko.com>
Thu, 7 Mar 2024 12:59:17 +0000 (07:59 -0500)
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.

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
common/autoboot.c

index 5d331991c1903f96bda428aa9b492f6b875e5fc6..6f0aeae6bf331afeb7ca0c365e3da078a653092b 100644 (file)
@@ -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 */