diff --git a/trusty/keymaster/trusty_keymaster_ipc.cpp b/trusty/keymaster/trusty_keymaster_ipc.cpp index fbd0eb396..686e7aec6 100644 --- a/trusty/keymaster/trusty_keymaster_ipc.cpp +++ b/trusty/keymaster/trusty_keymaster_ipc.cpp @@ -55,6 +55,11 @@ int trusty_keymaster_call(uint32_t cmd, void* in, uint32_t in_size, uint8_t* out size_t msg_size = in_size + sizeof(struct keymaster_message); struct keymaster_message* msg = reinterpret_cast(malloc(msg_size)); + if (!msg) { + ALOGE("failed to allocate msg buffer\n"); + return -EINVAL; + } + msg->cmd = cmd; memcpy(msg->payload, in, in_size);