Skip to content

Commit 8a0b8a8

Browse files
committed
[viogpu] Fix resource leak when cursor init fails
Similar to the framebuffer fix, add cleanup for GPU resource and ID when VioGpuObj::Init() or GpuObjectAttach() fails in CreateCursor(). Signed-off-by: xz-dev <xiangzhedev@gmail.com>
1 parent b4199d8 commit 8a0b8a8

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

viogpu/viogpudo/viogpudo.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3710,6 +3710,7 @@ BOOLEAN VioGpuAdapter::CreateCursor(_In_ CONST DXGKARG_SETPOINTERSHAPE *pSetPoin
37103710
{
37113711
UINT resid, format, size;
37123712
VioGpuObj *obj;
3713+
BOOLEAN status = TRUE;
37133714
PAGED_CODE();
37143715
DbgPrint(TRACE_LEVEL_INFORMATION,
37153716
("---> %s - %d: (%d x %d - %d) (%d + %d)\n",
@@ -3730,20 +3731,26 @@ BOOLEAN VioGpuAdapter::CreateCursor(_In_ CONST DXGKARG_SETPOINTERSHAPE *pSetPoin
37303731
obj = new (NonPagedPoolNx) VioGpuObj();
37313732
if (!obj->Init(size, &m_CursorSegment))
37323733
{
3733-
VioGpuDbgBreak();
37343734
DbgPrint(TRACE_LEVEL_FATAL, ("<--- %s Failed to init obj size = %d\n", __FUNCTION__, size));
3735-
delete obj;
3736-
return FALSE;
3735+
status = FALSE;
37373736
}
3738-
if (!GpuObjectAttach(resid, obj))
3737+
else if (!GpuObjectAttach(resid, obj))
37393738
{
3740-
VioGpuDbgBreak();
37413739
DbgPrint(TRACE_LEVEL_FATAL, ("<--- %s Failed to attach gpu object\n", __FUNCTION__));
3740+
status = FALSE;
3741+
}
3742+
if (!status)
3743+
{
3744+
VioGpuDbgBreak();
3745+
m_CtrlQueue.DestroyResource(resid);
3746+
m_Idr.PutId(resid);
37423747
delete obj;
3743-
return FALSE;
37443748
}
3745-
m_pCursorBuf = obj;
3746-
return TRUE;
3749+
else
3750+
{
3751+
m_pCursorBuf = obj;
3752+
}
3753+
return status;
37473754
}
37483755

37493756
BOOLEAN VioGpuAdapter::UpdateCursor(_In_ CONST DXGKARG_SETPOINTERSHAPE *pSetPointerShape,

0 commit comments

Comments
 (0)