From 2977bdb5288b958938a99ee279660a7a40dead70 Mon Sep 17 00:00:00 2001 From: Yang_Jiafeng Date: Tue, 26 Sep 2023 10:53:29 +0800 Subject: [PATCH] [VP] [Media Common]fix_linux_coverity_2 fix coverity issues --- media_driver/linux/common/ddi/media_libva.cpp | 43 ++----------------- .../linux/common/os/mos_context_specific.cpp | 5 --- .../common/os/mos_gpucontext_specific.cpp | 4 -- .../linux/common/os/mos_gpucontext_specific.h | 4 +- .../common/os/mos_graphicsresource_next.cpp | 4 ++ 5 files changed, 9 insertions(+), 51 deletions(-) diff --git a/media_driver/linux/common/ddi/media_libva.cpp b/media_driver/linux/common/ddi/media_libva.cpp index 34fd9c656da..b6f6c4bfdca 100755 --- a/media_driver/linux/common/ddi/media_libva.cpp +++ b/media_driver/linux/common/ddi/media_libva.cpp @@ -2472,44 +2472,7 @@ VAStatus DdiMedia_CreateSurfaces ( ) { DDI_FUNCTION_ENTER(); - int32_t event[] = {width, height, format}; - MOS_TraceEventExt(EVENT_VA_SURFACE, EVENT_TYPE_START, event, sizeof(event), nullptr, 0); - - DDI_CHK_NULL(ctx, "nullptr ctx", VA_STATUS_ERROR_INVALID_CONTEXT); - DDI_CHK_LARGER(num_surfaces, 0, "Invalid num_surfaces", VA_STATUS_ERROR_INVALID_PARAMETER); - DDI_CHK_NULL(surfaces, "nullptr surfaces", VA_STATUS_ERROR_INVALID_PARAMETER); - DDI_CHK_LARGER(width, 0, "Invalid width", VA_STATUS_ERROR_INVALID_PARAMETER); - DDI_CHK_LARGER(height, 0, "Invalid height", VA_STATUS_ERROR_INVALID_PARAMETER); - - PDDI_MEDIA_CONTEXT mediaDrvCtx = DdiMedia_GetMediaContext(ctx); - DDI_CHK_NULL(mediaDrvCtx, "nullptr mediaDrvCtx", VA_STATUS_ERROR_INVALID_CONTEXT); - - if( format != VA_RT_FORMAT_YUV420 || - format != VA_RT_FORMAT_YUV422 || - format != VA_RT_FORMAT_YUV444 || - format != VA_RT_FORMAT_YUV400 || - format != VA_RT_FORMAT_YUV411) - { - return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; - } - - DDI_MEDIA_FORMAT mediaFmt = DdiMedia_OsFormatToMediaFormat(VA_FOURCC_NV12,format); - - height = MOS_ALIGN_CEIL(height, 16); - for(int32_t i = 0; i < num_surfaces; i++) - { - VASurfaceID vaSurfaceID = (VASurfaceID)DdiMedia_CreateRenderTarget(mediaDrvCtx, mediaFmt, width, height, nullptr, VA_SURFACE_ATTRIB_USAGE_HINT_GENERIC, MOS_MEMPOOL_VIDEOMEMORY); - if (VA_INVALID_ID != vaSurfaceID) - surfaces[i] = vaSurfaceID; - else - { - // here to release the successful allocated surfaces? - return VA_STATUS_ERROR_ALLOCATION_FAILED; - } - } - - MOS_TraceEventExt(EVENT_VA_SURFACE, EVENT_TYPE_END, &num_surfaces, sizeof(int32_t), surfaces, num_surfaces*sizeof(VAGenericID)); - return VA_STATUS_SUCCESS; + return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; } VAStatus DdiMedia_DestroySurfaces ( @@ -2928,12 +2891,14 @@ VAStatus DdiMedia_CreateSurfaces2( if (eStatus != MOS_STATUS_SUCCESS) { DDI_VERBOSEMESSAGE("DDI:Failed to copy surface buffer data!"); + MOS_FreeMemAndSetNull(surfDesc); return VA_STATUS_ERROR_OPERATION_FAILED; } eStatus = MOS_SecureMemcpy(surfDesc->uiOffsets, sizeof(surfDesc->uiOffsets), externalBufDescripor.offsets, sizeof(externalBufDescripor.offsets)); if (eStatus != MOS_STATUS_SUCCESS) { DDI_VERBOSEMESSAGE("DDI:Failed to copy surface buffer data!"); + MOS_FreeMemAndSetNull(surfDesc); return VA_STATUS_ERROR_OPERATION_FAILED; } @@ -6927,8 +6892,6 @@ static uint32_t DdiMedia_GetPlaneNum(PDDI_MEDIA_SURFACE mediaSurface, bool hasAu case VA_FOURCC_P016: plane_num = hasAuxPlane ? 4 : 2; break; - plane_num = hasAuxPlane ? 4 : 2; - break; case VA_FOURCC_I420: case VA_FOURCC_YV12: case VA_FOURCC_411P: diff --git a/media_driver/linux/common/os/mos_context_specific.cpp b/media_driver/linux/common/os/mos_context_specific.cpp index 17ed090b29c..fc3441735b2 100644 --- a/media_driver/linux/common/os/mos_context_specific.cpp +++ b/media_driver/linux/common/os/mos_context_specific.cpp @@ -125,11 +125,6 @@ MOS_STATUS OsContextSpecific::DestroySemaphore(unsigned int semid) { int32_t nwait = 0; - if (semid < 0) - { - return MOS_STATUS_UNKNOWN; - } - nwait = semctl(semid, 0, GETZCNT, 0); if (nwait > 0) diff --git a/media_driver/linux/common/os/mos_gpucontext_specific.cpp b/media_driver/linux/common/os/mos_gpucontext_specific.cpp index 2c2a15aa845..b8da4747593 100644 --- a/media_driver/linux/common/os/mos_gpucontext_specific.cpp +++ b/media_driver/linux/common/os/mos_gpucontext_specific.cpp @@ -1145,10 +1145,6 @@ MOS_STATUS GpuContextSpecific::SubmitCommandBuffer( { execFlag = I915_EXEC_BSD | I915_EXEC_BSD_RING2; } - else if ((gpuNode == MOS_GPU_NODE_BLT)) - { - execFlag = I915_EXEC_BLT; - } else { MOS_OS_ASSERTMESSAGE("Invalid gpuNode."); diff --git a/media_driver/linux/common/os/mos_gpucontext_specific.h b/media_driver/linux/common/os/mos_gpucontext_specific.h index 7b77ddd3c69..4f5e4219343 100644 --- a/media_driver/linux/common/os/mos_gpucontext_specific.h +++ b/media_driver/linux/common/os/mos_gpucontext_specific.h @@ -262,7 +262,7 @@ class GpuContextSpecific : public GpuContext //! \brief Flag to indicate current command buffer flused or not, if not //! re-use it - volatile bool m_cmdBufFlushed; + volatile bool m_cmdBufFlushed = false; //! \brief internal back up for in-use command buffer PMOS_COMMAND_BUFFER m_commandBuffer = nullptr; @@ -292,7 +292,7 @@ class GpuContextSpecific : public GpuContext OsContext *m_osContext = nullptr; MOS_GPUCTX_CREATOPTIONS_ENHANCED *m_createOptionEnhanced = nullptr; - MOS_LINUX_CONTEXT* m_i915Context[MAX_ENGINE_INSTANCE_NUM+1]; + MOS_LINUX_CONTEXT* m_i915Context[MAX_ENGINE_INSTANCE_NUM+1] = {}; uint32_t m_i915ExecFlag = 0; #if (_DEBUG || _RELEASE_INTERNAL) diff --git a/media_softlet/agnostic/common/os/mos_graphicsresource_next.cpp b/media_softlet/agnostic/common/os/mos_graphicsresource_next.cpp index d83d5fb389a..d778b7a1395 100644 --- a/media_softlet/agnostic/common/os/mos_graphicsresource_next.cpp +++ b/media_softlet/agnostic/common/os/mos_graphicsresource_next.cpp @@ -118,6 +118,7 @@ MOS_STATUS GraphicsResourceNext::Dump(OsContextNext* osContextPtr, uint32_t over if (hFile != nullptr) { MosUtilities::MosCloseHandle(hFile); + hFile = nullptr; } return eStatus; } @@ -132,6 +133,7 @@ MOS_STATUS GraphicsResourceNext::Dump(OsContextNext* osContextPtr, uint32_t over if (hFile != nullptr) { MosUtilities::MosCloseHandle(hFile); + hFile = nullptr; } return MOS_STATUS_UNKNOWN; } @@ -151,6 +153,7 @@ MOS_STATUS GraphicsResourceNext::Dump(OsContextNext* osContextPtr, uint32_t over if (hFile != nullptr) { MosUtilities::MosCloseHandle(hFile); + hFile = nullptr; } } @@ -163,6 +166,7 @@ MOS_STATUS GraphicsResourceNext::Dump(OsContextNext* osContextPtr, uint32_t over if (hFile != nullptr) { MosUtilities::MosCloseHandle(hFile); + hFile = nullptr; } return eStatus;