Skip to content

Commit 9bbb29e

Browse files
xz-devYanVugenfirer
authored andcommitted
[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: xiangzhe <xiangzhedev@gmail.com>
1 parent 8c6211e commit 9bbb29e

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
@@ -3716,6 +3716,7 @@ BOOLEAN VioGpuAdapter::CreateCursor(_In_ CONST DXGKARG_SETPOINTERSHAPE *pSetPoin
37163716
{
37173717
UINT resid, format, size;
37183718
VioGpuObj *obj;
3719+
BOOLEAN status = TRUE;
37193720
PAGED_CODE();
37203721
DbgPrint(TRACE_LEVEL_INFORMATION,
37213722
("---> %s - %d: (%d x %d - %d) (%d + %d)\n",
@@ -3736,20 +3737,26 @@ BOOLEAN VioGpuAdapter::CreateCursor(_In_ CONST DXGKARG_SETPOINTERSHAPE *pSetPoin
37363737
obj = new (NonPagedPoolNx) VioGpuObj();
37373738
if (!obj->Init(size, &m_CursorSegment))
37383739
{
3739-
VioGpuDbgBreak();
37403740
DbgPrint(TRACE_LEVEL_FATAL, ("<--- %s Failed to init obj size = %d\n", __FUNCTION__, size));
3741-
delete obj;
3742-
return FALSE;
3741+
status = FALSE;
37433742
}
3744-
if (!GpuObjectAttach(resid, obj))
3743+
else if (!GpuObjectAttach(resid, obj))
37453744
{
3746-
VioGpuDbgBreak();
37473745
DbgPrint(TRACE_LEVEL_FATAL, ("<--- %s Failed to attach gpu object\n", __FUNCTION__));
3746+
status = FALSE;
3747+
}
3748+
if (status)
3749+
{
3750+
m_pCursorBuf = obj;
3751+
}
3752+
else
3753+
{
3754+
VioGpuDbgBreak();
3755+
m_CtrlQueue.DestroyResource(resid);
3756+
m_Idr.PutId(resid);
37483757
delete obj;
3749-
return FALSE;
37503758
}
3751-
m_pCursorBuf = obj;
3752-
return TRUE;
3759+
return status;
37533760
}
37543761

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

0 commit comments

Comments
 (0)