From: Dima Zavin Date: Tue, 4 Sep 2012 22:03:42 +0000 (-0700) Subject: exynos5: omx: osal: only free sharedmem buffers we allocated X-Git-Tag: cm-10.1-M1~194^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a6c8bcb6ee0f5ced4ab6ef80d3ed51642124ec8c;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung_slsi_exynos5.git exynos5: omx: osal: only free sharedmem buffers we allocated Buffers that get imported should not be freed as omx doesn't own them. Change-Id: I1667879937a2e855bbccc7276fa15eb333401dc9 Signed-off-by: Dima Zavin --- diff --git a/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_SharedMemory.c b/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_SharedMemory.c index d9aaee1..9d2dea3 100644 --- a/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_SharedMemory.c +++ b/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_SharedMemory.c @@ -25,6 +25,7 @@ * 2012.02.20 : Create */ +#include #include #include #include @@ -49,6 +50,7 @@ typedef struct _EXYNOS_SHAREDMEM_LIST OMX_U32 IONBuffer; OMX_PTR mapAddr; OMX_U32 allocSize; + bool owner; struct _EXYNOS_SHAREDMEM_LIST *pNextMemory; } EXYNOS_SHAREDMEM_LIST; @@ -109,7 +111,8 @@ void Exynos_OSAL_SharedMemory_Close(OMX_HANDLETYPE handle) pDeleteElement->mapAddr = NULL; pDeleteElement->allocSize = 0; - ion_free(pDeleteElement->IONBuffer); + if (pDeleteElement->owner) + ion_free(pDeleteElement->IONBuffer); pDeleteElement->IONBuffer = 0; Exynos_OSAL_Free(pDeleteElement); @@ -149,6 +152,7 @@ OMX_PTR Exynos_OSAL_SharedMemory_Alloc(OMX_HANDLETYPE handle, OMX_U32 size, MEMO pElement = (EXYNOS_SHAREDMEM_LIST *)Exynos_OSAL_Malloc(sizeof(EXYNOS_SHAREDMEM_LIST)); Exynos_OSAL_Memset(pElement, 0, sizeof(EXYNOS_SHAREDMEM_LIST)); + pElement->owner = true; switch (memoryType) { case SECURE_MEMORY: @@ -256,7 +260,8 @@ void Exynos_OSAL_SharedMemory_Free(OMX_HANDLETYPE handle, OMX_PTR pBuffer) pDeleteElement->mapAddr = NULL; pDeleteElement->allocSize = 0; - ion_free(pDeleteElement->IONBuffer); + if (pDeleteElement->owner) + ion_free(pDeleteElement->IONBuffer); pDeleteElement->IONBuffer = 0; Exynos_OSAL_Free(pDeleteElement);