Fix Coverity(1090031) for dereferencing potential NULL value 61/216561/2 accepted/tizen/unified/20191101.042202 submit/tizen/20191031.002509
authorDongsun Lee <ds73.lee@samsung.com>
Tue, 29 Oct 2019 02:11:37 +0000 (11:11 +0900)
committerDongsun Lee <ds73.lee@samsung.com>
Wed, 30 Oct 2019 00:49:26 +0000 (09:49 +0900)
Change-Id: I1ceb47eb7734779853f59657fa7c6d43062feb63
Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
ta/src/crypto_derive.c

index 75db9d545b1adf8b5b7ddd2cef38840fee18a63e..13a7ce07d29e415d708d59ba4fb25cafa10fd300 100644 (file)
@@ -100,6 +100,10 @@ TEE_Result KM_DeriveKey(void *pwd, uint32_t pwd_size, void *salt, uint32_t salt_
                hmacKeySize = 10;
        }
        hmacKeyBuffer = (char*)malloc(hmacKeySize);
+       if (!hmacKeyBuffer) {
+               LOG("Failed to allocate temp input memory for HMAC Key");
+               return TEE_ERROR_OUT_OF_MEMORY;
+       }
        if (pwd_size < 10) {
                KM_PadBuffer(KM_PADDING_ZERO, 10, pwd, pwd_size, hmacKeyBuffer, &hmacKeySize);
        } else {