VirtualBox

Changeset 52505 in vbox for trunk/src


Ignore:
Timestamp:
Aug 27, 2014 1:13:37 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95736
Message:

DrvHostBase: Provide I/O buffer allocator, fixes crash if a host DVD drive is attached to the AHCI controller without passthrough enabled and a medium inserted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DrvHostBase.cpp

    r51578 r52505  
    123123#include <iprt/critsect.h>
    124124#include <iprt/ctype.h>
     125#include <iprt/mem.h>
    125126
    126127#include "DrvHostBase.h"
     
    323324    return VINF_SUCCESS;
    324325}
     326
     327
     328/** @copydoc PDMIBLOCK::pfnIoBufAlloc */
     329static DECLCALLBACK(int) drvHostBaseIoBufAlloc(PPDMIBLOCK pInterface, size_t cb, void **ppvNew)
     330{
     331    LogFlowFunc(("\n"));
     332    int rc;
     333    PDRVHOSTBASE pThis = PDMIBLOCK_2_DRVHOSTBASE(pInterface);
     334
     335    void *pvNew = RTMemAlloc(cb);
     336    if (RT_LIKELY(pvNew))
     337    {
     338        *ppvNew = pvNew;
     339        rc = VINF_SUCCESS;
     340    }
     341    else
     342        rc = VERR_NO_MEMORY;
     343
     344    LogFlowFunc(("returns %Rrc\n", rc));
     345    return rc;
     346}
     347
     348/** @copydoc PDMIBLOCK::pfnIoBufFree */
     349static DECLCALLBACK(int) drvHostBaseIoBufFree(PPDMIBLOCK pInterface, void *pv, size_t cb)
     350{
     351    LogFlowFunc(("\n"));
     352    int rc = VINF_SUCCESS;
     353    PDRVHOSTBASE pThis = PDMIBLOCK_2_DRVHOSTBASE(pInterface);
     354
     355    NOREF(cb);
     356    RTMemFree(pv);
     357
     358    LogFlowFunc(("returns %Rrc\n", rc));
     359    return rc;
     360}
     361
    325362
    326363
     
    18911928    pThis->IBlock.pfnGetType                = drvHostBaseGetType;
    18921929    pThis->IBlock.pfnGetUuid                = drvHostBaseGetUuid;
     1930    pThis->IBlock.pfnIoBufAlloc             = drvHostBaseIoBufAlloc;
     1931    pThis->IBlock.pfnIoBufFree              = drvHostBaseIoBufFree;
    18931932
    18941933    /* IBlockBios. */
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