mirror of
https://github.com/NVIDIA/open-gpu-kernel-modules.git
synced 2026-03-07 22:29:53 +00:00
590.44.01
This commit is contained in:
@@ -146,10 +146,19 @@ NV_STATUS __nvoc_objCreate_KernelVgpuMgr(KernelVgpuMgr **ppThis, Dynamic *pParen
|
||||
Object *pParentObj = NULL;
|
||||
KernelVgpuMgr *pThis;
|
||||
|
||||
// Assign `pThis`, allocating memory unless suppressed by flag.
|
||||
status = __nvoc_handleObjCreateMemAlloc(createFlags, sizeof(KernelVgpuMgr), (void**)&pThis, (void**)ppThis);
|
||||
if (status != NV_OK)
|
||||
return status;
|
||||
// Don't allocate memory if the caller has already done so.
|
||||
if (createFlags & NVOC_OBJ_CREATE_FLAGS_IN_PLACE_CONSTRUCT)
|
||||
{
|
||||
NV_CHECK_OR_RETURN(LEVEL_ERROR, ppThis != NULL && *ppThis != NULL, NV_ERR_INVALID_PARAMETER);
|
||||
pThis = *ppThis;
|
||||
}
|
||||
|
||||
// Allocate memory
|
||||
else
|
||||
{
|
||||
pThis = portMemAllocNonPaged(sizeof(KernelVgpuMgr));
|
||||
NV_CHECK_OR_RETURN(LEVEL_ERROR, pThis != NULL, NV_ERR_NO_MEMORY);
|
||||
}
|
||||
|
||||
// Zero is the initial value for everything.
|
||||
portMemSet(pThis, 0, sizeof(KernelVgpuMgr));
|
||||
@@ -167,6 +176,7 @@ NV_STATUS __nvoc_objCreate_KernelVgpuMgr(KernelVgpuMgr **ppThis, Dynamic *pParen
|
||||
pThis->__nvoc_base_Object.pParent = NULL;
|
||||
}
|
||||
|
||||
// Initialize vtable, RTTI, etc., then call constructor.
|
||||
__nvoc_init__KernelVgpuMgr(pThis);
|
||||
status = __nvoc_ctor_KernelVgpuMgr(pThis);
|
||||
if (status != NV_OK) goto __nvoc_objCreate_KernelVgpuMgr_cleanup;
|
||||
@@ -174,24 +184,28 @@ NV_STATUS __nvoc_objCreate_KernelVgpuMgr(KernelVgpuMgr **ppThis, Dynamic *pParen
|
||||
// Assignment has no effect if NVOC_OBJ_CREATE_FLAGS_IN_PLACE_CONSTRUCT is set.
|
||||
*ppThis = pThis;
|
||||
|
||||
// Success
|
||||
return NV_OK;
|
||||
|
||||
// Do not call destructors here since the constructor already called them.
|
||||
__nvoc_objCreate_KernelVgpuMgr_cleanup:
|
||||
|
||||
// Unlink the child from the parent if it was linked above.
|
||||
if (pParentObj != NULL)
|
||||
objRemoveChild(pParentObj, &pThis->__nvoc_base_Object);
|
||||
|
||||
// Do not call destructors here since the constructor already called them.
|
||||
// Zero out memory that was allocated by caller.
|
||||
if (createFlags & NVOC_OBJ_CREATE_FLAGS_IN_PLACE_CONSTRUCT)
|
||||
portMemSet(pThis, 0, sizeof(KernelVgpuMgr));
|
||||
|
||||
// Free memory allocated by `__nvoc_handleObjCreateMemAlloc`.
|
||||
else
|
||||
{
|
||||
portMemFree(pThis);
|
||||
*ppThis = NULL;
|
||||
}
|
||||
|
||||
// coverity[leaked_storage:FALSE]
|
||||
// Failure
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user