From: Taehwan Kim Date: Fri, 22 Feb 2013 09:05:56 +0000 (+0000) Subject: osal: resolved prevent defect X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=15bc171e25f559fd20f9390da57bd1346f574a23;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung_slsi_openmax.git osal: resolved prevent defect - 19329, 21140 Change-Id: I21cb12259bedfcb69699b10445d738fed1a1636a Signed-off-by: Taehwan Kim --- diff --git a/osal/Exynos_OSAL_SharedMemory.c b/osal/Exynos_OSAL_SharedMemory.c index 8471916..bfec218 100644 --- a/osal/Exynos_OSAL_SharedMemory.c +++ b/osal/Exynos_OSAL_SharedMemory.c @@ -36,6 +36,7 @@ #include #include +#include "Exynos_OSAL_Mutex.h" #include "Exynos_OSAL_SharedMemory.h" #include "ion.h" @@ -69,9 +70,9 @@ OMX_HANDLETYPE Exynos_OSAL_SharedMemory_Open() ion_client IONClient = 0; pHandle = (EXYNOS_SHARED_MEMORY *)Exynos_OSAL_Malloc(sizeof(EXYNOS_SHARED_MEMORY)); - Exynos_OSAL_Memset(pHandle, 0, sizeof(EXYNOS_SHARED_MEMORY)); if (pHandle == NULL) goto EXIT; + Exynos_OSAL_Memset(pHandle, 0, sizeof(EXYNOS_SHARED_MEMORY)); IONClient = ion_client_create(); if (IONClient < 0) { @@ -83,7 +84,14 @@ OMX_HANDLETYPE Exynos_OSAL_SharedMemory_Open() pHandle->hIONHandle = IONClient; - Exynos_OSAL_MutexCreate(&pHandle->hSMMutex); + if (OMX_ErrorNone != Exynos_OSAL_MutexCreate(&pHandle->hSMMutex)) { + Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Exynos_OSAL_MutexCreate(hSMMutex) is failed"); + ion_client_destroy((ion_client)pHandle->hIONHandle); + pHandle->hIONHandle = NULL; + + Exynos_OSAL_Free((void *)pHandle); + pHandle = NULL; + } EXIT: return (OMX_HANDLETYPE)pHandle; @@ -153,6 +161,8 @@ OMX_PTR Exynos_OSAL_SharedMemory_Alloc(OMX_HANDLETYPE handle, OMX_U32 size, MEMO goto EXIT; pElement = (EXYNOS_SHAREDMEM_LIST *)Exynos_OSAL_Malloc(sizeof(EXYNOS_SHAREDMEM_LIST)); + if (pElement == NULL) + goto EXIT; Exynos_OSAL_Memset(pElement, 0, sizeof(EXYNOS_SHAREDMEM_LIST)); pElement->owner = OMX_TRUE; @@ -179,6 +189,8 @@ OMX_PTR Exynos_OSAL_SharedMemory_Alloc(OMX_HANDLETYPE handle, OMX_U32 size, MEMO flag = ION_EXYNOS_MFC_INPUT_MASK; break; default: + Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "memory type is wrong"); + Exynos_OSAL_Free((OMX_PTR)pElement); pBuffer = NULL; goto EXIT; break;