VirtualBox

Changeset 93991 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Feb 28, 2022 4:29:55 PM (3 years ago)
Author:
vboxsync
Message:

VMM: Fix a possible PDM queue leak when destroying a VM, bugref:10093

Location:
trunk/src/VBox/VMM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/PDM.cpp

    r93901 r93991  
    888888
    889889    /*
     890     * Cleanup any leftover queues.
     891     */
     892    pdmR3QueueTerm(pVM);
     893
     894    /*
    890895     * Destroy the PDM lock.
    891896     */
  • trunk/src/VBox/VMM/VMMR3/PDMQueue.cpp

    r93900 r93991  
    433433                hQueue--;
    434434            pVM->pdm.s.cRing3Queues = hQueue;
    435             /** @todo this should be done by PDMR3Term not here. */
    436             if (!hQueue)
    437             {
    438                 pVM->pdm.s.cRing3QueuesAlloc = 0;
    439                 PPDMQUEUE *papQueuesOld = ASMAtomicXchgPtrT(&pVM->pdm.s.papRing3Queues, NULL, PPDMQUEUE *);
    440                 RTMemFree(papQueuesOld);
    441             }
    442435        }
    443436        pQueue->u32Magic = PDMQUEUE_MAGIC_DEAD;
     
    801794}
    802795
     796
     797/**
     798 * Terminate the queues, freeing any resources still allocated.
     799 *
     800 * @returns nothing.
     801 * @param   pVM                 The cross-context VM structure.
     802 */
     803DECLHIDDEN(void) pdmR3QueueTerm(PVM pVM)
     804{
     805    if (pVM->pdm.s.papRing3Queues)
     806    {
     807        /*
     808         * Free the R3 queue handle array.
     809         */
     810        PDMQUEUEHANDLE cQueues = pVM->pdm.s.cRing3Queues;
     811        for (PDMQUEUEHANDLE i = 0; i < cQueues; i++)
     812            if (pVM->pdm.s.papRing3Queues[i])
     813            {
     814                PPDMQUEUE pQueue = pVM->pdm.s.papRing3Queues[i];
     815
     816                PDMR3QueueDestroy(pVM, RT_ELEMENTS(pVM->pdm.s.apRing0Queues) + i, pQueue->u.Gen.pvOwner);
     817                Assert(!pVM->pdm.s.papRing3Queues[i]);
     818            }
     819
     820        RTMemFree(pVM->pdm.s.papRing3Queues);
     821        pVM->pdm.s.cRing3QueuesAlloc = 0;
     822        pVM->pdm.s.papRing3Queues    = NULL;
     823    }
     824}
  • trunk/src/VBox/VMM/include/PDMInternal.h

    r93635 r93991  
    18091809void        pdmR3BlkCacheTerm(PVM pVM);
    18101810int         pdmR3BlkCacheResume(PVM pVM);
     1811
     1812DECLHIDDEN(void) pdmR3QueueTerm(PVM pVM);
    18111813#endif /* IN_RING3 */
    18121814
Note: See TracChangeset for help on using the changeset viewer.

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