diff options
author | Sarthak Aggarwal <sarthak@ti.com> | 2011-09-12 03:45:21 +0530 |
---|---|---|
committer | Iliyan Malchev <malchev@google.com> | 2011-09-12 11:44:59 -0700 |
commit | e005708a4599caa650c653028bea2ccb216fc653 (patch) | |
tree | 43012f07381e08d8ac60d8c88cb8f782d2f262a8 | |
parent | ba027fc89ec3950e1ac2f95fcc3f1002442ddabb (diff) | |
download | hardware_ti_omap4xxx-e005708a4599caa650c653028bea2ccb216fc653.zip hardware_ti_omap4xxx-e005708a4599caa650c653028bea2ccb216fc653.tar.gz hardware_ti_omap4xxx-e005708a4599caa650c653028bea2ccb216fc653.tar.bz2 |
DOMX: Do proper clean up even in case of error in GetHandle
In case of some error during GetHandle, there was a double
free of a pointer which was finally leading to a seg fault.
This patch rectifies that clean up path.
Change-Id: Ia24fc746d9a274ac0b7bea4b2dfbcde657b15c13
Signed-off-by: Sarthak Aggarwal <sarthak@ti.com>
-rwxr-xr-x | domx/domx/omx_rpc/src/omx_rpc.c | 18 | ||||
-rwxr-xr-x | domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c | 1 | ||||
-rwxr-xr-x | domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c | 1 |
3 files changed, 16 insertions, 4 deletions
diff --git a/domx/domx/omx_rpc/src/omx_rpc.c b/domx/domx/omx_rpc/src/omx_rpc.c index 78ae973..ff1022b 100755 --- a/domx/domx/omx_rpc/src/omx_rpc.c +++ b/domx/domx/omx_rpc/src/omx_rpc.c @@ -109,6 +109,9 @@ RPC_OMX_ERRORTYPE RPC_InstanceInit(OMX_STRING cComponentName, struct omx_conn_req sReq = { .name = "OMX" }; TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE; OMX_U32 i = 0; + + *(RPC_OMX_CONTEXT **) phRPCCtx = NULL; + //pthread_t cbThread; // sReq.name = "OMX"; @@ -120,7 +123,6 @@ RPC_OMX_ERRORTYPE RPC_InstanceInit(OMX_STRING cComponentName, RPC_assert(pRPCCtx != NULL, RPC_OMX_ErrorInsufficientResources, "Malloc failed"); TIMM_OSAL_Memset(pRPCCtx, 0, sizeof(RPC_OMX_CONTEXT)); - *(RPC_OMX_CONTEXT **) phRPCCtx = pRPCCtx; /*Assuming that open maintains an internal count for multi instance */ DOMX_DEBUG("Calling open on the device"); @@ -164,6 +166,10 @@ RPC_OMX_ERRORTYPE RPC_InstanceInit(OMX_STRING cComponentName, { RPC_InstanceDeInit(pRPCCtx); } + else + { + *(RPC_OMX_CONTEXT **) phRPCCtx = pRPCCtx; + } return eRPCError; } @@ -188,7 +194,7 @@ RPC_OMX_ERRORTYPE RPC_InstanceDeInit(OMX_HANDLETYPE hRPCCtx) OMX_U64 nKillEvent = 1; RPC_assert(hRPCCtx != NULL, RPC_OMX_ErrorUndefined, - "NULL context handle supplied - no further cleanup possible"); + "NULL context handle supplied to RPC Deinit"); if (pRPCCtx->fd_killcb) { @@ -211,6 +217,7 @@ RPC_OMX_ERRORTYPE RPC_InstanceDeInit(OMX_HANDLETYPE hRPCCtx) } DOMX_DEBUG("Closing the kill fd"); status = close(pRPCCtx->fd_killcb); + pRPCCtx->fd_killcb = 0; if (status != 0) { DOMX_ERROR("Close failed on kill fd"); @@ -223,6 +230,7 @@ RPC_OMX_ERRORTYPE RPC_InstanceDeInit(OMX_HANDLETYPE hRPCCtx) if (pRPCCtx->pMsgPipe[i]) { eError = TIMM_OSAL_DeletePipe(pRPCCtx->pMsgPipe[i]); + pRPCCtx->pMsgPipe[i] = NULL; if (eError != TIMM_OSAL_ERR_NONE) { DOMX_ERROR("Pipe deletion failed"); @@ -235,16 +243,18 @@ RPC_OMX_ERRORTYPE RPC_InstanceDeInit(OMX_HANDLETYPE hRPCCtx) if (pRPCCtx->fd_omx) { status = close(pRPCCtx->fd_omx); + pRPCCtx->fd_omx = 0; if (status != 0) { DOMX_ERROR("Close failed on omx fd"); eRPCError = RPC_OMX_ErrorUndefined; } } + TIMM_OSAL_Free(pRPCCtx); - EXIT: - return eRPCError; + EXIT: + return eRPCError; } diff --git a/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c b/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c index 9f5ce7b..16589c0 100755 --- a/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c +++ b/domx/omx_proxy_component/omx_camera/src/omx_proxy_camera.c @@ -333,6 +333,7 @@ OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) DOMX_ERROR("\Error in Initializing Proxy"); TIMM_OSAL_Free(pComponentPrivate->cCompName); TIMM_OSAL_Free(pComponentPrivate); + goto EXIT; } pHandle->ComponentDeInit = ComponentPrivateDeInit; diff --git a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c index 618daac..572592b 100755 --- a/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c +++ b/domx/omx_proxy_component/omx_video_dec/src/omx_proxy_videodec.c @@ -184,6 +184,7 @@ OMX_ERRORTYPE OMX_ProxyViddecInit(OMX_HANDLETYPE hComponent) (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate; eError = OMX_ProxyCommonInit(hComponent); // Calling Proxy Common Init() + PROXY_assert(eError == OMX_ErrorNone, eError, "Proxy common init returned error"); #ifdef ANDROID_QUIRK_CHANGE_PORT_VALUES pHandle->SetParameter = PROXY_VIDDEC_SetParameter; pHandle->GetParameter = PROXY_VIDDEC_GetParameter; |