VirtualBox

Changeset 30860 in vbox for trunk/src


Ignore:
Timestamp:
Jul 15, 2010 5:19:32 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
63689
Message:

GMMR0.cpp: fixed impossible leak in GMMR0SeekChunk. nits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/GMMR0.cpp

    r30790 r30860  
    489489
    490490    /** Shared module tree (global). */
    491     /** todo seperate trees for distinctly different guest OSes. */
     491    /** @todo seperate trees for distinctly different guest OSes. */
    492492    PAVLGCPTRNODECORE   pGlobalSharedModuleTree;
    493493
     
    867867             * pages will be 'left behind'.)
    868868             */
    869             /* todo this might be kind of expensive with a lot of VMs and memory hanging around... */
     869            /** @todo this might be kind of expensive with a lot of VMs and
     870             *   memory hanging around... */
    870871            uint64_t cPrivatePages = pGVM->gmm.s.cPrivatePages; /* save */
    871872            RTAvlU32DoWithAll(&pGMM->pChunks, true /* fFromLeft */, gmmR0CleanupVMScanChunk, pGVM);
     
    34603461        /* Grab the lock. */
    34613462        rc = RTSemFastMutexRequest(pGMM->Mtx);
    3462         AssertRCReturn(rc, rc);
    3463 
    3464         /*
    3465          * Add a new chunk with our hGVM.
    3466          */
    3467         rc = gmmR0RegisterChunk(pGMM, &pGMM->Private, MemObj, pGVM->hSelf, GMMCHUNKTYPE_NON_CONTINUOUS);
    3468         RTSemFastMutexRelease(pGMM->Mtx);
     3463        AssertRC(rc);
     3464        if (RT_SUCCESS(rc))
     3465        {
     3466            /*
     3467             * Add a new chunk with our hGVM.
     3468             */
     3469            rc = gmmR0RegisterChunk(pGMM, &pGMM->Private, MemObj, pGVM->hSelf, GMMCHUNKTYPE_NON_CONTINUOUS);
     3470            RTSemFastMutexRelease(pGMM->Mtx);
     3471        }
    34693472
    34703473        if (RT_FAILURE(rc))
     
    34943497    if (    pInfo
    34953498        &&  pInfo->enmGuestOS == pModule->enmGuestOS
    3496         /** todo replace with RTStrNCmp */
     3499        /** @todo replace with RTStrNCmp */
    34973500        &&  !strcmp(pModule->szName, pInfo->pszModuleName)
    34983501        &&  !strcmp(pModule->szVersion, pInfo->pszVersion))
     
    36173620            pGlobalModule->cbModule = cbModule;
    36183621            /* Input limit already safe; no need to check again. */
    3619             /** todo replace with RTStrCopy */
     3622            /** @todo replace with RTStrCopy */
    36203623            strcpy(pGlobalModule->szName, pszModuleName);
    36213624            strcpy(pGlobalModule->szVersion, pszVersion);
     
    36493652
    36503653            /* Make sure the name and version are identical. */
    3651             /** todo replace with RTStrNCmp */
     3654            /** @todo replace with RTStrNCmp */
    36523655            if (    !strcmp(pGlobalModule->szName, pszModuleName)
    36533656                &&  !strcmp(pGlobalModule->szVersion, pszVersion))
     
    37433746    {
    37443747        PGMMSHAREDMODULEPERVM pRecVM = (PGMMSHAREDMODULEPERVM)RTAvlGCPtrGet(&pGVM->gmm.s.pSharedModuleTree, GCBaseAddr);
    3745         if (!pRecVM)
    3746         {
    3747             rc = VERR_PGM_SHARED_MODULE_NOT_FOUND;
    3748             goto end;
    3749         }
    3750         /* Remove reference to global shared module. */
    3751         if (!pRecVM->fCollision)
    3752         {
    3753             PGMMSHAREDMODULE pRec = pRecVM->pGlobalModule;
    3754             Assert(pRec);
    3755 
    3756             if (pRec)   /* paranoia */
     3748        if (pRecVM)
     3749        {
     3750            /* Remove reference to global shared module. */
     3751            if (!pRecVM->fCollision)
    37573752            {
    3758                 Assert(pRec->cUsers);
    3759                 pRec->cUsers--;
    3760                 if (pRec->cUsers == 0)
     3753                PGMMSHAREDMODULE pRec = pRecVM->pGlobalModule;
     3754                Assert(pRec);
     3755
     3756                if (pRec)   /* paranoia */
    37613757                {
    3762                     /* Free the ranges, but leave the pages intact as there might still be references; they will be cleared by the COW mechanism. */
    3763                     for (unsigned i = 0; i < pRec->cRegions; i++)
    3764                         if (pRec->aRegions[i].paHCPhysPageID)
    3765                             RTMemFree(pRec->aRegions[i].paHCPhysPageID);
    3766 
    3767                     /* Remove from the tree and free memory. */
    3768                     RTAvlGCPtrRemove(&pGMM->pGlobalSharedModuleTree, GCBaseAddr);
    3769                     RTMemFree(pRec);
     3758                    Assert(pRec->cUsers);
     3759                    pRec->cUsers--;
     3760                    if (pRec->cUsers == 0)
     3761                    {
     3762                        /* Free the ranges, but leave the pages intact as there might still be references; they will be cleared by the COW mechanism. */
     3763                        for (unsigned i = 0; i < pRec->cRegions; i++)
     3764                            if (pRec->aRegions[i].paHCPhysPageID)
     3765                                RTMemFree(pRec->aRegions[i].paHCPhysPageID);
     3766
     3767                        /* Remove from the tree and free memory. */
     3768                        RTAvlGCPtrRemove(&pGMM->pGlobalSharedModuleTree, GCBaseAddr);
     3769                        RTMemFree(pRec);
     3770                    }
    37703771                }
     3772                else
     3773                    rc = VERR_PGM_SHARED_MODULE_REGISTRATION_INCONSISTENCY;
    37713774            }
    37723775            else
    3773                 rc = VERR_PGM_SHARED_MODULE_REGISTRATION_INCONSISTENCY;
     3776                Assert(!pRecVM->pGlobalModule);
     3777
     3778            /* Remove from the tree and free memory. */
     3779            RTAvlGCPtrRemove(&pGVM->gmm.s.pSharedModuleTree, GCBaseAddr);
     3780            RTMemFree(pRecVM);
    37743781        }
    37753782        else
    3776             Assert(!pRecVM->pGlobalModule);
    3777 
    3778         /* Remove from the tree and free memory. */
    3779         RTAvlGCPtrRemove(&pGVM->gmm.s.pSharedModuleTree, GCBaseAddr);
    3780         RTMemFree(pRecVM);
     3783            rc = VERR_PGM_SHARED_MODULE_NOT_FOUND;
    37813784
    37823785        GMM_CHECK_SANITY_UPON_LEAVING(pGMM);
     
    37853788        rc = VERR_INTERNAL_ERROR_5;
    37863789
    3787 end:
    37883790    RTSemFastMutexRelease(pGMM->Mtx);
    37893791    return rc;
     
    39043906        {
    39053907            /* Page was freed at some point; invalidate this entry. */
    3906             /** todo this isn't really bullet proof. */
     3908            /** @todo this isn't really bullet proof. */
    39073909            Log(("Old shared page was freed -> create a new one\n"));
    39083910            pGlobalRegion->paHCPhysPageID[idxPage] = NIL_GMM_PAGEID;
     
    39483950        pbSharedPage = pbChunk + ((pGlobalRegion->paHCPhysPageID[idxPage] & GMM_PAGEID_IDX_MASK) << PAGE_SHIFT);
    39493951
    3950         /** todo write ASMMemComparePage. */
     3952        /** @todo write ASMMemComparePage. */
    39513953        if (memcmp(pbSharedPage, pbLocalPage, PAGE_SIZE))
    39523954        {
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette