Skip to content

Commit c3c05ee

Browse files
xiaoton1intel-mediadev
authored andcommitted
[VP] Fix potential failure in VphalState::~VphalState
If vphalDevice->m_vphalState has been created, osInterface should be released in VphalState::~VphalState. Change-Id: I7b8b8c388f84632c75b89ed329caa986510b643d
1 parent 4137c0c commit c3c05ee

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

media_driver/linux/common/media_interfaces/media_interfaces.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,15 @@ VphalState* VphalDevice::CreateFactory(
129129
if (vphalDevice->Initialize(osInterface, osDriverContext, eStatus) != MOS_STATUS_SUCCESS)
130130
{
131131
VPHAL_DEBUG_ASSERTMESSAGE("VPHal interfaces were not successfully allocated!");
132-
if (osInterface->bDeallocateOnExit)
132+
133+
// If m_vphalState has been created, osInterface should be released in VphalState::~VphalState.
134+
if (osInterface->bDeallocateOnExit && nullptr == vphalDevice->m_vphalState)
133135
{
136+
// Deallocate OS interface structure (except if externally provided)
137+
if (osInterface->pfnDestroy)
138+
{
139+
osInterface->pfnDestroy(osInterface, true);
140+
}
134141
MOS_FreeMemAndSetNull(osInterface);
135142
}
136143
vphalDevice->Destroy();

0 commit comments

Comments
 (0)