Skip to content

Commit

Permalink
Revert "[CM] Fix some coverity issue"
Browse files Browse the repository at this point in the history
This reverts commit 17bb7c8.
  • Loading branch information
pinglux authored and intel-mediadev committed Oct 12, 2023
1 parent 2451cc4 commit d320ebe
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
2 changes: 0 additions & 2 deletions media_driver/agnostic/common/cm/cm_kernel_ex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,8 @@ CmSurfaceState* CmKernelEx::GetSurfaceState(CmSurface *surface, uint32_t index)
}
default:
{
break;
}
}
break;
}
case CM_ENUM_CLASS_TYPE_CMSURFACESAMPLER8X8:
{
Expand Down
15 changes: 15 additions & 0 deletions media_driver/agnostic/common/cm/cm_kernel_rt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,11 @@ int32_t CmKernelRT::SetArgsInternal( CM_KERNEL_INTERNAL_ARG_TYPE nArgType, uint3
( m_args[ index ].unitKind == ARG_KIND_STATE_BUFFER ) ) && surfIndexValue )
{
CmSafeMemSet((void *)arg.surfIndex, 0, size/sizeof(int32_t) * sizeof(uint16_t));
if( surfIndexValue == nullptr )
{
CM_ASSERTMESSAGE("Error: Pointer to surface index value is null.");
return CM_NULL_POINTER;
}
CmSafeMemCopy((void *)arg.surfIndex, surfIndexValue, size/sizeof(int32_t) * sizeof(uint16_t));
}

Expand Down Expand Up @@ -2072,6 +2077,11 @@ int32_t CmKernelRT::SetArgsInternal( CM_KERNEL_INTERNAL_ARG_TYPE nArgType, uint3
return CM_OUT_OF_HOST_MEMORY;
}
CmSafeMemSet((void *)arg.surfIndex, 0, size/sizeof(uint32_t) * sizeof(uint16_t) * m_threadCount);
if( surfIndexValue == nullptr )
{
CM_ASSERTMESSAGE("Error: Pointer to surface index value is null.");
return CM_NULL_POINTER;
}
CmSafeMemCopy((void *)(arg.surfIndex + size/sizeof(uint32_t) * nThreadID), surfIndexValue, size/sizeof(uint32_t) * sizeof(uint16_t));
}
m_perThreadArgExists = true;
Expand Down Expand Up @@ -2107,6 +2117,11 @@ int32_t CmKernelRT::SetArgsInternal( CM_KERNEL_INTERNAL_ARG_TYPE nArgType, uint3
( m_args[ index ].unitKind == ARG_KIND_SURFACE_2D_SCOREBOARD) ||
( m_args[ index ].unitKind == ARG_KIND_STATE_BUFFER ) ) && surfIndexValue )
{
if( surfIndexValue == nullptr )
{
CM_ASSERTMESSAGE("Error: Pointer to surface index value is null.");
return CM_NULL_POINTER;
}
CmSafeMemCopy((void *)(arg.surfIndex + size/sizeof(uint32_t) * nThreadID), surfIndexValue, size/sizeof(uint32_t) * sizeof(uint16_t));
}
}
Expand Down
4 changes: 2 additions & 2 deletions media_driver/agnostic/common/cm/cm_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ int32_t CmProgramRT::Initialize( void* cisaCode, const uint32_t cisaCodeSize, co
}
CmSafeMemSet( errorMsg, 0, CM_JIT_ERROR_MESSAGE_SIZE );

FINALIZER_INFO *jitProfInfo = (FINALIZER_INFO *)malloc(sizeof(FINALIZER_INFO));
FINALIZER_INFO *jitProfInfo = (FINALIZER_INFO *)malloc(CM_JIT_PROF_INFO_SIZE);
if(jitProfInfo == nullptr)
{
CM_ASSERTMESSAGE("Error: Out of system memory.");
Expand All @@ -590,7 +590,7 @@ int32_t CmProgramRT::Initialize( void* cisaCode, const uint32_t cisaCodeSize, co
hr = CM_OUT_OF_HOST_MEMORY;
goto finish;
}
CmSafeMemSet(jitProfInfo, 0, sizeof(FINALIZER_INFO));
CmSafeMemSet( jitProfInfo, 0, CM_JIT_PROF_INFO_SIZE );

void *extra_info = nullptr;
CmNotifierGroup *notifiers = m_device->GetNotifiers();
Expand Down
10 changes: 9 additions & 1 deletion media_driver/agnostic/common/cm/cm_queue_rt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2301,7 +2301,6 @@ void BufferCopyThread(void* threadData)
CmEvent* wait_event = (CmEvent*)(data->wait_event);
CmEvent* notify_event = (CmEvent*)(data->event);
CmEventRT* eventRT = dynamic_cast<CmEventRT*>(notify_event);
CM_CHK_NULL_RETURN_VOID(eventRT);
CmEventEx* eex = dynamic_cast<CmEventEx*>(notify_event);

uint32_t offset = data->offset;
Expand Down Expand Up @@ -2464,6 +2463,15 @@ int32_t CmQueueRT::EnqueueBufferCopy(CmBuffer* buffer, size_t offset, const unsi
CM_CHK_NULL_GOTOFINISH_CMERROR(task);
CM_CHK_CMSTATUS_GOTOFINISH(task->AddKernel(kernel));

if (option & CM_FASTCOPY_OPTION_DISABLE_TURBO_BOOST)
{
// disable turbo
CM_TASK_CONFIG taskConfig;
CmSafeMemSet(&taskConfig, 0, sizeof(CM_TASK_CONFIG));
taskConfig.turboBoostFlag = CM_TURBO_BOOST_DISABLE;
task->SetProperty(taskConfig);
}

CM_CHK_CMSTATUS_GOTOFINISH(EnqueueFast(task, event, threadSpace));
}

Expand Down
4 changes: 2 additions & 2 deletions media_driver/agnostic/common/cm/cm_surface_3d_rt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ CM_RT_API int32_t CmSurface3DRT::WriteSurface( const unsigned char* sysMem,
return CM_INVALID_ARG_VALUE;
}

uSizeInBytes = (uint64_t)(m_width * m_height * m_depth * pixel);
uSizeInBytes = m_width * m_height * m_depth * pixel;
if (sysMemSize < uSizeInBytes)
{
CM_ASSERTMESSAGE("Error: Invalid copy size.")
Expand Down Expand Up @@ -257,7 +257,7 @@ CM_RT_API int32_t CmSurface3DRT::ReadSurface( unsigned char* sysMem, CmEvent* ev
return CM_INVALID_ARG_VALUE;
}

uSizeInBytes = (uint64_t)(m_width * m_height * m_depth * pixel);
uSizeInBytes = m_width * m_height * m_depth * pixel;
if (sysMemSize < uSizeInBytes)
{
CM_ASSERTMESSAGE("Error: Invalid copy size.")
Expand Down
10 changes: 4 additions & 6 deletions media_driver/agnostic/common/cm/cm_visa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ ISAfile::ISAfile(const ISAfile& other) {
data = other.data;
end = other.end;
size = other.size;
unsigned int error_length = std::strlen(other.error) + 1;
char *perror = new char[error_length];
MOS_SecureMemcpy(perror, error_length, other.error, error_length);
char *perror = new char[std::strlen(other.error)];
MOS_SecureMemcpy(perror, sizeof(perror), other.error, sizeof(other.error));
error = perror;
kernel_data_loaded = other.kernel_data_loaded;
function_data_loaded = other.function_data_loaded;
Expand All @@ -67,9 +66,8 @@ ISAfile& ISAfile::operator= (const ISAfile& other) {
end = other.end;
size = other.size;
delete[] error;
unsigned int error_length = std::strlen(other.error) + 1;
char *perror = new char[error_length];
MOS_SecureMemcpy(perror, error_length, other.error, error_length);
char *perror = new char[std::strlen(other.error)];
MOS_SecureMemcpy(perror, sizeof perror, other.error, sizeof other.error);
error = perror;
kernel_data_loaded = other.kernel_data_loaded;
function_data_loaded = other.function_data_loaded;
Expand Down

0 comments on commit d320ebe

Please sign in to comment.