Skip to content

Commit

Permalink
[CM] Fix coverity CM resource leak issue
Browse files Browse the repository at this point in the history
Clean resource leak issue of CM
  • Loading branch information
XuanJessica authored and intel-mediadev committed Oct 9, 2023
1 parent 05e4d0d commit 176a5c3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion media_driver/agnostic/common/cm/cm_device_rt_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,13 @@ class CmDeviceRTBase: public CmDevice

CmDeviceRTBase(uint32_t DevCreateOption);

~CmDeviceRTBase() {};
~CmDeviceRTBase()
{
if (m_notifierGroup != nullptr)
{
delete m_notifierGroup;
}
}

void DestructCommon();

Expand Down
10 changes: 8 additions & 2 deletions media_driver/agnostic/common/cm/cm_execution_adv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,17 @@ int CmExecutionAdv::SubmitGpgpuTask(CMRT_UMD::CmQueueRT *queue,

cmdBuf->AddSipState(cmish->GetSipKernelOffset());

CM_CHK_MOSSTATUS_RETURN(m_cmhal->osInterface->pfnRegisterResource(
MOS_STATUS eStatus = m_cmhal->osInterface->pfnRegisterResource(
m_cmhal->osInterface,
&m_cmhal->csrResource,
true,
true));
true);

if (eStatus != MOS_STATUS_SUCCESS)
{
cmdsh->DestroyMediaState(cmMediaState);
return eStatus;
}

cmdBuf->AddCsrBaseAddress(&m_cmhal->csrResource);

Expand Down
2 changes: 2 additions & 0 deletions media_driver/agnostic/common/cm/cm_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10545,6 +10545,8 @@ MOS_STATUS HalCm_Create(
else
{
CM_ASSERTMESSAGE("Allocate MhwInterfaces failed");
HalCm_Destroy(state);
*cmState = nullptr;
return MOS_STATUS_NO_SPACE;
}
}
Expand Down

0 comments on commit 176a5c3

Please sign in to comment.