Skip to content

Commit

Permalink
[VP] [Media Common]fix_linux_coverity_2
Browse files Browse the repository at this point in the history
fix coverity issues
  • Loading branch information
jiafengy1 authored and intel-mediadev committed Sep 26, 2023
1 parent 94542db commit 2977bdb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 51 deletions.
43 changes: 3 additions & 40 deletions media_driver/linux/common/ddi/media_libva.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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:
Expand Down
5 changes: 0 additions & 5 deletions media_driver/linux/common/os/mos_context_specific.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions media_driver/linux/common/os/mos_gpucontext_specific.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
4 changes: 2 additions & 2 deletions media_driver/linux/common/os/mos_gpucontext_specific.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ MOS_STATUS GraphicsResourceNext::Dump(OsContextNext* osContextPtr, uint32_t over
if (hFile != nullptr)
{
MosUtilities::MosCloseHandle(hFile);
hFile = nullptr;
}
return eStatus;
}
Expand All @@ -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;
}
Expand All @@ -151,6 +153,7 @@ MOS_STATUS GraphicsResourceNext::Dump(OsContextNext* osContextPtr, uint32_t over
if (hFile != nullptr)
{
MosUtilities::MosCloseHandle(hFile);
hFile = nullptr;
}
}

Expand All @@ -163,6 +166,7 @@ MOS_STATUS GraphicsResourceNext::Dump(OsContextNext* osContextPtr, uint32_t over
if (hFile != nullptr)
{
MosUtilities::MosCloseHandle(hFile);
hFile = nullptr;
}

return eStatus;
Expand Down

0 comments on commit 2977bdb

Please sign in to comment.