Skip to content

Commit

Permalink
[CM] Coverity issue clean up for uninitialized and nullptr
Browse files Browse the repository at this point in the history
Cleanup Coverity issues including uninitialized pointers/scala, unchecked return, dereference and division by zero
  • Loading branch information
jingyansc authored and intel-mediadev committed Sep 27, 2023
1 parent 8dc2e2e commit f4391fa
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion media_driver/agnostic/common/cm/cm_command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ MOS_STATUS CmCommandBuffer::AddMediaObjectWalker(CMRT_UMD::CmThreadSpaceRT *thre
{
case CM_WALK_DEFAULT:
case CM_WALK_HORIZONTAL:
if (threadSpaceWidth == threadCount && threadSpaceHeight == 1)
if (threadSpaceWidth == threadCount && threadSpaceHeight == 1 && maxThreadWidth)
{
mediaWalkerParams.BlockResolution.x = MOS_MIN(threadCount, maxThreadWidth);
mediaWalkerParams.BlockResolution.y = 1 + threadCount / maxThreadWidth;
Expand Down
17 changes: 7 additions & 10 deletions media_driver/agnostic/common/cm/cm_kernel_rt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6189,22 +6189,19 @@ int CmKernelRT::UpdateSamplerHeap(CmKernelData *kernelData)
}
}

if(!sampler.btiMultiplier)
{
CM_ASSERTMESSAGE("Sampler BTI setting error. Multiplier cannot be zero!\n");
return MOS_STATUS_INVALID_PARAMETER;
}

if (iter == sampler_heap->end())
{
// Aligns heapOffset to next nearest multiple of sampler size if next sampler is a different element type
heapOffset = (heapOffset + sampler.btiStepping * sampler.btiMultiplier - 1) / (sampler.btiStepping * sampler.btiMultiplier) * (sampler.btiStepping * sampler.btiMultiplier);
}
sampler.heapOffset = heapOffset;

if (sampler.btiMultiplier != 0)
{
sampler.bti = sampler.heapOffset / sampler.btiMultiplier;
}
else
{
CM_ASSERTMESSAGE("Sampler BTI setting error. Multiplier cannot be zero!\n");
return MOS_STATUS_INVALID_PARAMETER;
}
sampler.bti = sampler.heapOffset / sampler.btiMultiplier;
sampler_heap->insert(iter, sampler);
}
}
Expand Down
3 changes: 1 addition & 2 deletions media_driver/agnostic/common/cm/cm_ssh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ CmSSH::CmSSH(CM_HAL_STATE *cmhal, PMOS_COMMAND_BUFFER cmdBuf):
m_curSsIndex(0),
m_cmhal(cmhal),
m_renderhal(nullptr),
m_resCount(0),
m_occupiedBteIndexes(nullptr)
m_resCount(0)
{
}

Expand Down
4 changes: 2 additions & 2 deletions media_driver/agnostic/common/cm/cm_visa.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ namespace vISA {
//!
//! \brief Constructor of Field struct.
//!
Field(Datatype t) : type(t), countField(0), number64(0) {}
Field(Datatype t) : type(t), countField(0), size(0), number64(0) {}

//!
//! \brief Constructor of Field struct.
//!
Field(Datatype t, uint8_t cf) : type(t), countField(cf), number64(0) {}
Field(Datatype t, uint8_t cf) : type(t), countField(cf), size(0), number64(0) {}

//!
//! \brief Destructor of Field struct.
Expand Down

0 comments on commit f4391fa

Please sign in to comment.