From 2144622d123eef33bddeae194b29516b78cb8575 Mon Sep 17 00:00:00 2001 From: ShawnLi Date: Tue, 23 Jul 2019 14:06:19 +0800 Subject: [PATCH] [Decode] Fix kw issues Possible memory leak Change-Id: I2f22b4135d8e25d11afa8385ae45702eb1b97b09 --- media_driver/linux/common/ddi/media_libva.cpp | 1 + media_driver/linux/common/ddi/media_libva_common.cpp | 1 + .../linux/common/ddi/media_libva_putsurface_linux.cpp | 8 +++++++- media_driver/linux/common/os/i915/mos_bufmgr.c | 1 + media_driver/linux/common/os/mos_utilities_specific.c | 3 +++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/media_driver/linux/common/ddi/media_libva.cpp b/media_driver/linux/common/ddi/media_libva.cpp index 630e50be0be..b52a78b7a03 100755 --- a/media_driver/linux/common/ddi/media_libva.cpp +++ b/media_driver/linux/common/ddi/media_libva.cpp @@ -2162,6 +2162,7 @@ DdiMedia_CreateSurfaces2( surfDesc->uiTile = I915_TILING_NONE; if (surfDesc->ulBuffer % 4096 != 0) { + MOS_FreeMemory(surfDesc); DDI_VERBOSEMESSAGE("Buffer Address is invalid"); return VA_STATUS_ERROR_INVALID_PARAMETER; } diff --git a/media_driver/linux/common/ddi/media_libva_common.cpp b/media_driver/linux/common/ddi/media_libva_common.cpp index 26a78ed9728..fedf06a801f 100644 --- a/media_driver/linux/common/ddi/media_libva_common.cpp +++ b/media_driver/linux/common/ddi/media_libva_common.cpp @@ -336,6 +336,7 @@ PDDI_MEDIA_SURFACE DdiMedia_ReplaceSurfaceWithNewFormat(PDDI_MEDIA_SURFACE surfa PDDI_MEDIA_SURFACE dstSurface = (DDI_MEDIA_SURFACE *)MOS_AllocAndZeroMemory(sizeof(DDI_MEDIA_SURFACE)); if (nullptr == surfaceElement) { + MOS_FreeMemory(dstSurface); return nullptr; } diff --git a/media_driver/linux/common/ddi/media_libva_putsurface_linux.cpp b/media_driver/linux/common/ddi/media_libva_putsurface_linux.cpp index 5569e2ecaea..1cb2a6762df 100644 --- a/media_driver/linux/common/ddi/media_libva_putsurface_linux.cpp +++ b/media_driver/linux/common/ddi/media_libva_putsurface_linux.cpp @@ -870,7 +870,13 @@ VAStatus DdiMedia_PutSurfaceLinuxSW( uint8_t *umdContextY = dispTempBuffer; uint8_t *ptr = (uint8_t*)DdiMediaUtil_LockSurface(mediaSurface, (MOS_LOCKFLAG_READONLY | MOS_LOCKFLAG_WRITEONLY)); MOS_STATUS eStatus = MOS_SecureMemcpy(umdContextY, surfaceSize, ptr, surfaceSize); - DDI_CHK_CONDITION((eStatus != MOS_STATUS_SUCCESS), "DDI:Failed to copy surface buffer data!", VA_STATUS_ERROR_OPERATION_FAILED); + + if (eStatus != MOS_STATUS_SUCCESS) + { + MOS_FreeMemory(dispTempBuffer); + DDI_ASSERTMESSAGE("DDI:Failed to copy surface buffer data!"); + return VA_STATUS_ERROR_OPERATION_FAILED; + } Visual *visual = DefaultVisual(ctx->native_dpy, ctx->x11_screen); GC gc = (*pfn_XCreateGC)((Display*)ctx->native_dpy, (Drawable)draw, 0, nullptr); diff --git a/media_driver/linux/common/os/i915/mos_bufmgr.c b/media_driver/linux/common/os/i915/mos_bufmgr.c index c58f7520142..dab9cf45831 100644 --- a/media_driver/linux/common/os/i915/mos_bufmgr.c +++ b/media_driver/linux/common/os/i915/mos_bufmgr.c @@ -3979,6 +3979,7 @@ struct drm_i915_gem_vm_control* mos_gem_vm_create(struct mos_bufmgr *bufmgr) if (ret != 0) { MOS_DBG("DRM_IOCTL_I915_GEM_VM_CREATE failed: %s\n", strerror(errno)); + free(vm); return nullptr; } diff --git a/media_driver/linux/common/os/mos_utilities_specific.c b/media_driver/linux/common/os/mos_utilities_specific.c index ea2683fb5d9..ef7d94b8287 100644 --- a/media_driver/linux/common/os/mos_utilities_specific.c +++ b/media_driver/linux/common/os/mos_utilities_specific.c @@ -1228,6 +1228,7 @@ static MOS_STATUS _UserFeature_SetValue( if ( (eStatus = _UserFeature_DumpFile(szUserFeatureFile, &pKeyList)) != MOS_STATUS_SUCCESS ) { + MOS_FreeMemory(pKeyList); return eStatus; } @@ -1330,6 +1331,7 @@ static MOS_STATUS _UserFeature_GetKeyIdbyName(const char *pcKeyName, void **pUF if ( (eStatus = _UserFeature_DumpFile(szUserFeatureFile, &pKeyList)) != MOS_STATUS_SUCCESS ) { + MOS_FreeMemory(pKeyList); return eStatus; } @@ -1382,6 +1384,7 @@ static MOS_STATUS _UserFeature_GetKeyNamebyId(void *UFKey, char *pcKeyName) if ( (eStatus = _UserFeature_DumpFile(szUserFeatureFile, &pKeyList)) != MOS_STATUS_SUCCESS ) { + MOS_FreeMemory(pKeyList); return eStatus; }