From: Krzysztof Dynowski Date: Thu, 22 Feb 2018 14:47:20 +0000 (+0100) Subject: Fix return origin in open command X-Git-Tag: accepted/tizen/unified/20180413.073549~31 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=367408b570327d86b191ee822cd46ec1b5e4f82b;p=platform%2Fcore%2Fsecurity%2Ftef-simulator.git Fix return origin in open command Change-Id: Iddc7ede6fe28fee099a0e33bb2e786461266fffc --- diff --git a/TEECLib/src/teec_api.c b/TEECLib/src/teec_api.c index 3ceee06..cd887ad 100644 --- a/TEECLib/src/teec_api.c +++ b/TEECLib/src/teec_api.c @@ -1098,6 +1098,11 @@ TEEC_Result TEEC_OpenSession(TEEC_Context *context, TEEC_Session *session, memset(tmpSharedMem, 0x0, sizeof(tmpSharedMem)); + // Set returnOrigin + if (returnOrigin) { + *returnOrigin = TEEC_ORIGIN_API; + } + // Check if the context, session and UUID is valid if (!session || !context || !destination) { LOGE(TEEC_LIB, "Invalid input parameters"); @@ -1123,12 +1128,7 @@ TEEC_Result TEEC_OpenSession(TEEC_Context *context, TEEC_Session *session, */ memset(&os, 0x00, sizeof(OpenSessionData)); memset(&op, 0x00, sizeof(OperationData)); - - // Set returnOrigin - if (returnOrigin) { - *returnOrigin = TEEC_ORIGIN_API; - os.returnOrigin = *returnOrigin; - } else os.returnOrigin = 0x00; + os.returnOrigin = TEEC_ORIGIN_API; // Update Context ID os.contextID = context_imp->contextID; diff --git a/TEEStub/TACommands/CommandOpenSession.cpp b/TEEStub/TACommands/CommandOpenSession.cpp index 4d24654..7a8eddb 100644 --- a/TEEStub/TACommands/CommandOpenSession.cpp +++ b/TEEStub/TACommands/CommandOpenSession.cpp @@ -52,19 +52,19 @@ TEE_Result CommandOpenSession::execute() { // If param. type is of memory reference type then allocate shared memory bool sharedResult = true; TOGGLE_PROPERTY_ACCESS; + data.returnOrigin = TEE_ORIGIN_TEE; sharedResult = SharedMemoryMap::allocateSharedMemory(data.op); if (sharedResult) { + data.returnOrigin = TEE_ORIGIN_TRUSTED_APP; data.returnValue = TA_OpenSessionEntryPoint(data.op.paramTypes, data.op.params, &sessionContext); LOGD(TEE_STUB, "TA_OpenSessionEntryPoint done"); } else { - data.returnOrigin = TEE_ORIGIN_TRUSTED_APP; data.returnValue = TEE_ERROR_OUT_OF_MEMORY; } sharedResult = SharedMemoryMap::deleteSharedMemory(data.op); if (!sharedResult) { - data.returnOrigin = TEE_ORIGIN_TRUSTED_APP; - data.returnValue = TEE_ERROR_OUT_OF_MEMORY; + LOGE(TEE_STUB, "deleteSharedMemory failed"); } TOGGLE_PROPERTY_ACCESS; return data.returnValue;