VirtualBox

Changeset 45061 in vbox


Ignore:
Timestamp:
Mar 18, 2013 2:09:03 PM (12 years ago)
Author:
vboxsync
Message:

Review of PDM driver destructors making sure that variables they use are correctly initialized in the constructor. Found several RTFileClose(0) cases.

Location:
trunk/src/VBox
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DrvNAT.cpp

    r45047 r45061  
    11711171
    11721172    /*
     1173     * Init the static parts.
     1174     */
     1175    pThis->pDrvIns                      = pDrvIns;
     1176    pThis->pNATState                    = NULL;
     1177    pThis->pszTFTPPrefix                = NULL;
     1178    pThis->pszBootFile                  = NULL;
     1179    pThis->pszNextServer                = NULL;
     1180    pThis->hSlirpReqQueue               = NIL_RTREQQUEUE;
     1181    pThis->hUrgRecvReqQueue             = NIL_RTREQQUEUE;
     1182    pThis->EventRecv                    = NIL_RTSEMEVENT;
     1183    pThis->EventUrgRecv                 = NIL_RTSEMEVENT;
     1184
     1185    /* IBase */
     1186    pDrvIns->IBase.pfnQueryInterface    = drvNATQueryInterface;
     1187
     1188    /* INetwork */
     1189    pThis->INetworkUp.pfnBeginXmit          = drvNATNetworkUp_BeginXmit;
     1190    pThis->INetworkUp.pfnAllocBuf           = drvNATNetworkUp_AllocBuf;
     1191    pThis->INetworkUp.pfnFreeBuf            = drvNATNetworkUp_FreeBuf;
     1192    pThis->INetworkUp.pfnSendBuf            = drvNATNetworkUp_SendBuf;
     1193    pThis->INetworkUp.pfnEndXmit            = drvNATNetworkUp_EndXmit;
     1194    pThis->INetworkUp.pfnSetPromiscuousMode = drvNATNetworkUp_SetPromiscuousMode;
     1195    pThis->INetworkUp.pfnNotifyLinkChanged  = drvNATNetworkUp_NotifyLinkChanged;
     1196
     1197    /* NAT engine configuration */
     1198    pThis->INetworkNATCfg.pfnRedirectRuleCommand = drvNATNetworkNatConfig_RedirectRuleCommand;
     1199
     1200    /*
    11731201     * Validate the config.
    11741202     */
     
    11871215                                N_("Unknown NAT configuration option, only supports PassDomain,"
    11881216                                " TFTPPrefix, BootFile and Network"));
    1189 
    1190     /*
    1191      * Init the static parts.
    1192      */
    1193     pThis->pDrvIns                      = pDrvIns;
    1194     pThis->pNATState                    = NULL;
    1195     pThis->pszTFTPPrefix                = NULL;
    1196     pThis->pszBootFile                  = NULL;
    1197     pThis->pszNextServer                = NULL;
    1198     pThis->hSlirpReqQueue               = NIL_RTREQQUEUE;
    1199     pThis->hUrgRecvReqQueue             = NIL_RTREQQUEUE;
    1200     pThis->EventRecv                    = NIL_RTSEMEVENT;
    1201     pThis->EventUrgRecv                 = NIL_RTSEMEVENT;
    1202 
    1203     /* IBase */
    1204     pDrvIns->IBase.pfnQueryInterface    = drvNATQueryInterface;
    1205 
    1206     /* INetwork */
    1207     pThis->INetworkUp.pfnBeginXmit          = drvNATNetworkUp_BeginXmit;
    1208     pThis->INetworkUp.pfnAllocBuf           = drvNATNetworkUp_AllocBuf;
    1209     pThis->INetworkUp.pfnFreeBuf            = drvNATNetworkUp_FreeBuf;
    1210     pThis->INetworkUp.pfnSendBuf            = drvNATNetworkUp_SendBuf;
    1211     pThis->INetworkUp.pfnEndXmit            = drvNATNetworkUp_EndXmit;
    1212     pThis->INetworkUp.pfnSetPromiscuousMode = drvNATNetworkUp_SetPromiscuousMode;
    1213     pThis->INetworkUp.pfnNotifyLinkChanged  = drvNATNetworkUp_NotifyLinkChanged;
    1214 
    1215     /* NAT engine configuration */
    1216     pThis->INetworkNATCfg.pfnRedirectRuleCommand = drvNATNetworkNatConfig_RedirectRuleCommand;
    12171217
    12181218    /*
  • trunk/src/VBox/Devices/Network/DrvNetShaper.cpp

    r44528 r45061  
    427427    pThis->INetworkUpR3.pfnSetPromiscuousMode       = drvNetShaperUp_SetPromiscuousMode;
    428428    pThis->INetworkUpR3.pfnNotifyLinkChanged        = drvR3NetShaperUp_NotifyLinkChanged;
    429     /*
    430      * Resolve the ring-0 context interface addresses.
    431      */
     429    /* Resolve the ring-0 context interface addresses. */
    432430    int rc = pDrvIns->pHlpR3->pfnLdrGetR0InterfaceSymbols(pDrvIns, &pThis->INetworkUpR0,
    433431                                                          sizeof(pThis->INetworkUpR0),
  • trunk/src/VBox/Devices/Network/DrvNetSniffer.cpp

    r44528 r45061  
    358358        RTCritSectDelete(&pThis->XmitLock);
    359359
    360     RTFileClose(pThis->hFile);
    361     pThis->hFile = NIL_RTFILE;
     360    if (pThis->hFile != NIL_RTFILE)
     361    {
     362        RTFileClose(pThis->hFile);
     363        pThis->hFile = NIL_RTFILE;
     364    }
    362365}
    363366
  • trunk/src/VBox/Devices/Network/DrvTAP.cpp

    r44580 r45061  
    777777     */
    778778    int rc;
    779     rc = RTPipeClose(pThis->hPipeWrite); AssertRC(rc);
    780     pThis->hPipeWrite = NIL_RTPIPE;
    781     rc = RTPipeClose(pThis->hPipeRead); AssertRC(rc);
    782     pThis->hPipeRead = NIL_RTPIPE;
     779    if (pThis->hPipeWrite != NIL_RTPIPE)
     780    {
     781        rc = RTPipeClose(pThis->hPipeWrite); AssertRC(rc);
     782        pThis->hPipeWrite = NIL_RTPIPE;
     783    }
     784    if (pThis->hPipeRead != NIL_RTPIPE)
     785    {
     786        rc = RTPipeClose(pThis->hPipeRead); AssertRC(rc);
     787        pThis->hPipeRead = NIL_RTPIPE;
     788    }
    783789
    784790#ifdef RT_OS_SOLARIS
     
    786792    if (pThis->hFileDevice != NIL_RTFILE)
    787793    {
    788         int rc = RTFileClose(pThis->hFileDevice);
    789         AssertRC(rc);
     794        int rc = RTFileClose(pThis->hFileDevice); AssertRC(rc);
    790795        pThis->hFileDevice = NIL_RTFILE;
    791796    }
     
    808813    MMR3HeapFree(pThis->pszDeviceName);
    809814#endif
     815    pThis->pszDeviceName = NULL;
    810816    MMR3HeapFree(pThis->pszSetupApplication);
     817    pThis->pszSetupApplication = NULL;
    811818    MMR3HeapFree(pThis->pszTerminateApplication);
     819    pThis->pszTerminateApplication = NULL;
    812820
    813821    /*
     
    846854    pThis->pDrvIns                      = pDrvIns;
    847855    pThis->hFileDevice                  = NIL_RTFILE;
     856    pThis->hPipeWrite                   = NIL_RTPIPE;
     857    pThis->hPipeRead                    = NIL_RTPIPE;
    848858    pThis->pszDeviceName                = NULL;
    849859#ifdef RT_OS_SOLARIS
  • trunk/src/VBox/Devices/Network/DrvUDPTunnel.cpp

    r44528 r45061  
    404404
    405405    if (pThis->pszInstance)
     406    {
    406407        RTStrFree(pThis->pszInstance);
     408        pThis->pszInstance = NULL;
     409    }
    407410
    408411    if (pThis->pszDestIP)
     412    {
    409413        MMR3HeapFree(pThis->pszDestIP);
     414        pThis->pszDestIP = NULL;
     415    }
    410416
    411417    if (pThis->pServer)
  • trunk/src/VBox/Devices/Network/DrvVDE.cpp

    r44528 r45061  
    481481     * Terminate the control pipe.
    482482     */
    483     RTPipeClose(pThis->hPipeWrite);
    484     pThis->hPipeWrite = NIL_RTPIPE;
    485     RTPipeClose(pThis->hPipeRead);
    486     pThis->hPipeRead = NIL_RTPIPE;
     483    if (pThis->hPipeWrite != NIL_RTPIPE)
     484    {
     485        RTPipeClose(pThis->hPipeWrite);
     486        pThis->hPipeWrite = NIL_RTPIPE;
     487    }
     488    if (pThis->hPipeRead != NIL_RTPIPE)
     489    {
     490        RTPipeClose(pThis->hPipeRead);
     491        pThis->hPipeRead = NIL_RTPIPE;
     492    }
    487493
    488494    MMR3HeapFree(pThis->pszDeviceName);
     495    pThis->pszDeviceName = NULL;
    489496
    490497    /*
     
    494501        RTCritSectDelete(&pThis->XmitLock);
    495502
    496     vde_close(pThis->pVdeConn);
    497     pThis->pVdeConn = NULL;
     503    if (pThis->pVdeConn)
     504    {
     505        vde_close(pThis->pVdeConn);
     506        pThis->pVdeConn = NULL;
     507    }
    498508
    499509#ifdef VBOX_WITH_STATISTICS
  • trunk/src/VBox/Devices/PC/DrvACPI.cpp

    r44528 r45061  
    925925
    926926#ifdef RT_OS_LINUX
    927     RTSemEventDestroy(pThis->hPollerSleepEvent);
    928     pThis->hPollerSleepEvent = NIL_RTSEMEVENT;
     927    if (pThis->hPollerSleepEvent != NIL_RTSEMEVENT)
     928    {
     929        RTSemEventDestroy(pThis->hPollerSleepEvent);
     930        pThis->hPollerSleepEvent = NIL_RTSEMEVENT;
     931    }
    929932    RTCritSectDelete(&pThis->CritSect);
    930933#endif
     
    946949     */
    947950    pThis->pDrvIns                              = pDrvIns;
     951#ifdef RT_OS_LINUX
     952    pThis->hPollerSleepEvent                    = NIL_RTSEMEVENT;
     953#endif
    948954    /* IBase */
    949955    pDrvIns->IBase.pfnQueryInterface            = drvACPIQueryInterface;
  • trunk/src/VBox/Devices/PC/DrvAcpiCpu.cpp

    r44528 r45061  
    3838    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
    3939    return NULL;
    40 }
    41 
    42 /**
    43  * Destruct a driver instance.
    44  *
    45  * Most VM resources are freed by the VM. This callback is provided so that any non-VM
    46  * resources can be freed correctly.
    47  *
    48  * @param   pDrvIns     The driver instance data.
    49  */
    50 static DECLCALLBACK(void) drvACPICpuDestruct(PPDMDRVINS pDrvIns)
    51 {
    52     LogFlow(("drvACPICpuDestruct\n"));
    53     PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
    5440}
    5541
     
    11197    drvACPICpuConstruct,
    11298    /* pfnDestruct */
    113     drvACPICpuDestruct,
     99    NULL,
    114100    /* pfnRelocate */
    115101    NULL,
  • trunk/src/VBox/Devices/Parallel/DrvHostParallel.cpp

    r43458 r45061  
    873873        ioctl(RTFileToNative(pThis->hFileDevice), PPRELEASE);
    874874
    875     rc = RTPipeClose(pThis->hWakeupPipeW); AssertRC(rc);
    876     pThis->hWakeupPipeW = NIL_RTPIPE;
    877 
    878     rc = RTPipeClose(pThis->hWakeupPipeR); AssertRC(rc);
    879     pThis->hWakeupPipeR = NIL_RTPIPE;
    880 
    881     rc = RTFileClose(pThis->hFileDevice); AssertRC(rc);
    882     pThis->hFileDevice = NIL_RTFILE;
     875    if (pThis->hWakeupPipeW != NIL_RTPIPE)
     876    {
     877        rc = RTPipeClose(pThis->hWakeupPipeW); AssertRC(rc);
     878        pThis->hWakeupPipeW = NIL_RTPIPE;
     879    }
     880
     881    if (pThis->hWakeupPipeR != NIL_RTPIPE)
     882    {
     883        rc = RTPipeClose(pThis->hWakeupPipeR); AssertRC(rc);
     884        pThis->hWakeupPipeR = NIL_RTPIPE;
     885    }
     886
     887    if (pThis->hFileDevice != NIL_RTFILE)
     888    {
     889        rc = RTFileClose(pThis->hFileDevice); AssertRC(rc);
     890        pThis->hFileDevice = NIL_RTFILE;
     891    }
    883892
    884893    if (pThis->pszDevicePath)
     
    887896        pThis->pszDevicePath = NULL;
    888897    }
    889 #else /* VBOX_WITH_WIN_PARPORT_SUP */
     898#else  /* VBOX_WITH_WIN_PARPORT_SUP */
    890899    if (pThis->hWinFileDevice != NIL_RTFILE)
     900    {
    891901        rc = RTFileClose(pThis->hWinFileDevice); AssertRC(rc);
     902        pThis->hWinFileDevice = NIL_RTFILE;
     903    }
    892904#endif /* VBOX_WITH_WIN_PARPORT_SUP */
    893905}
     
    914926    pThis->hWakeupPipeR = NIL_RTPIPE;
    915927    pThis->hWakeupPipeW = NIL_RTPIPE;
    916 #else /* VBOX_WITH_WIN_PARPORT_SUP */
     928#else
    917929    pThis->hWinFileDevice = NIL_RTFILE;
    918930#endif
  • trunk/src/VBox/Devices/Serial/DrvChar.cpp

    r44528 r45061  
    305305    {
    306306        RTSemEventSignal(pThis->SendSem);
     307        pThis->SendSem = NIL_RTSEMEVENT;
    307308    }
    308309
  • trunk/src/VBox/Devices/Serial/DrvHostSerial.cpp

    r44528 r45061  
    10701070
    10711071    /* Empty the send queue */
    1072     RTSemEventDestroy(pThis->SendSem);
    1073     pThis->SendSem = NIL_RTSEMEVENT;
     1072    if (pThis->SendSem != NIL_RTSEMEVENT)
     1073    {
     1074        RTSemEventDestroy(pThis->SendSem);
     1075        pThis->SendSem = NIL_RTSEMEVENT;
     1076    }
    10741077
    10751078    int rc;
     
    10921095    }
    10931096# endif
    1094     rc = RTFileClose(pThis->hDeviceFile); AssertRC(rc);
    1095     pThis->hDeviceFile = NIL_RTFILE;
     1097    if (pThis->hDeviceFile != NIL_RTFILE)
     1098    {
     1099        rc = RTFileClose(pThis->hDeviceFile); AssertRC(rc);
     1100        pThis->hDeviceFile = NIL_RTFILE;
     1101    }
    10961102
    10971103#elif defined(RT_OS_WINDOWS)
     
    11361142    pThis->hDeviceFile = INVALID_HANDLE_VALUE;
    11371143#endif
     1144    pThis->SendSem     = NIL_RTSEMEVENT;
    11381145    /* IBase. */
    11391146    pDrvIns->IBase.pfnQueryInterface        = drvHostSerialQueryInterface;
     
    11431150    pThis->ICharConnector.pfnSetModemLines  = drvHostSerialSetModemLines;
    11441151    pThis->ICharConnector.pfnSetBreak       = drvHostSerialSetBreak;
    1145 
    1146 /** @todo Initialize all members with NIL values!! The destructor is ALWAYS called. */
    11471152
    11481153    /*
  • trunk/src/VBox/Devices/Serial/DrvRawFile.cpp

    r44528 r45061  
    140140        MMR3HeapFree(pThis->pszLocation);
    141141
    142     RTFileClose(pThis->hOutputFile);
    143     pThis->hOutputFile = NIL_RTFILE;
     142    if (pThis->hOutputFile != NIL_RTFILE)
     143    {
     144        RTFileClose(pThis->hOutputFile);
     145        pThis->hOutputFile = NIL_RTFILE;
     146    }
    144147}
    145148
  • trunk/src/VBox/Devices/Storage/DrvHostBase.cpp

    r44528 r45061  
    18781878    pThis->enmType                          = enmType;
    18791879    //pThis->cErrors                          = 0;
     1880    pThis->fAttachFailError                 = true; /* It's an error until we've read the config. */
    18801881
    18811882    pThis->pfnGetMediaSize                  = drvHostBaseGetMediaSize;
  • trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp

    r40282 r45061  
    759759
    760760    /*
    761      * Validate configuration.
    762      */
    763     if (!CFGMR3AreValuesValid(pCfg, "Path\0Interval\0Locked\0BIOSVisible\0AttachFailError\0Passthrough\0"))
    764         return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
    765 
    766 
    767     /*
    768761     * Init instance data.
    769762     */
     
    772765    {
    773766        /*
    774          * Override stuff.
     767         * Validate configuration.
    775768         */
     769        if (CFGMR3AreValuesValid(pCfg, "Path\0Interval\0Locked\0BIOSVisible\0AttachFailError\0Passthrough\0"))
     770        {
     771            /*
     772             * Override stuff.
     773             */
    776774#ifdef RT_OS_LINUX
    777         pThis->pbDoubleBuffer = (uint8_t *)RTMemAlloc(SCSI_MAX_BUFFER_SIZE);
    778         if (!pThis->pbDoubleBuffer)
    779             return VERR_NO_MEMORY;
     775            pThis->pbDoubleBuffer = (uint8_t *)RTMemAlloc(SCSI_MAX_BUFFER_SIZE);
     776            if (!pThis->pbDoubleBuffer)
     777                return VERR_NO_MEMORY;
    780778#endif
    781779
    782780#ifndef RT_OS_L4 /* Passthrough is not supported on L4 yet */
    783         bool fPassthrough;
    784         rc = CFGMR3QueryBool(pCfg, "Passthrough", &fPassthrough);
    785         if (RT_SUCCESS(rc) && fPassthrough)
     781            bool fPassthrough;
     782            rc = CFGMR3QueryBool(pCfg, "Passthrough", &fPassthrough);
     783            if (RT_SUCCESS(rc) && fPassthrough)
     784            {
     785                pThis->IBlock.pfnSendCmd = drvHostDvdSendCmd;
     786                /* Passthrough requires opening the device in R/W mode. */
     787                pThis->fReadOnlyConfig = false;
     788# ifdef VBOX_WITH_SUID_WRAPPER  /* Solaris setuid for Passthrough mode. */
     789                rc = solarisCheckUserAuth();
     790                if (RT_FAILURE(rc))
     791                {
     792                    Log(("DVD: solarisCheckUserAuth failed. Permission denied!\n"));
     793                    return rc;
     794                }
     795# endif /* VBOX_WITH_SUID_WRAPPER */
     796            }
     797#endif /* !RT_OS_L4 */
     798
     799            pThis->IMount.pfnUnmount = drvHostDvdUnmount;
     800            pThis->pfnDoLock         = drvHostDvdDoLock;
     801#ifdef USE_MEDIA_POLLING
     802            if (!fPassthrough)
     803                pThis->pfnPoll       = drvHostDvdPoll;
     804            else
     805                pThis->pfnPoll       = NULL;
     806#endif
     807#ifdef RT_OS_LINUX
     808            pThis->pfnGetMediaSize   = drvHostDvdGetMediaSize;
     809#endif
     810
     811            /*
     812             * 2nd init part.
     813             */
     814            rc = DRVHostBaseInitFinish(pThis);
     815        }
     816        else
    786817        {
    787             pThis->IBlock.pfnSendCmd = drvHostDvdSendCmd;
    788             /* Passthrough requires opening the device in R/W mode. */
    789             pThis->fReadOnlyConfig = false;
    790 # ifdef VBOX_WITH_SUID_WRAPPER  /* Solaris setuid for Passthrough mode. */
    791             rc = solarisCheckUserAuth();
    792             if (RT_FAILURE(rc))
    793             {
    794                 Log(("DVD: solarisCheckUserAuth failed. Permission denied!\n"));
    795                 return rc;
    796             }
    797 # endif /* VBOX_WITH_SUID_WRAPPER */
     818            pThis->fAttachFailError = true;
     819            rc = VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
    798820        }
    799 #endif /* !RT_OS_L4 */
    800 
    801         pThis->IMount.pfnUnmount = drvHostDvdUnmount;
    802         pThis->pfnDoLock         = drvHostDvdDoLock;
    803 #ifdef USE_MEDIA_POLLING
    804         if (!fPassthrough)
    805             pThis->pfnPoll       = drvHostDvdPoll;
    806         else
    807             pThis->pfnPoll       = NULL;
    808 #endif
    809 #ifdef RT_OS_LINUX
    810         pThis->pfnGetMediaSize   = drvHostDvdGetMediaSize;
    811 #endif
    812 
    813         /*
    814          * 2nd init part.
    815          */
    816         rc = DRVHostBaseInitFinish(pThis);
    817821    }
    818822    if (RT_FAILURE(rc))
  • trunk/src/VBox/Devices/Storage/DrvHostFloppy.cpp

    r44528 r45061  
    185185
    186186    /*
    187      * Validate configuration.
    188      */
    189     if (!CFGMR3AreValuesValid(pCfg, "Path\0ReadOnly\0Interval\0Locked\0BIOSVisible\0"))
    190         return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
    191 
    192     /*
    193187     * Init instance data.
    194188     */
     
    197191    {
    198192        /*
    199          * Override stuff.
     193         * Validate configuration.
    200194         */
     195        if (CFGMR3AreValuesValid(pCfg, "Path\0ReadOnly\0Interval\0Locked\0BIOSVisible\0"))
     196        {
     197            /*
     198             * Override stuff.
     199             */
    201200#ifdef RT_OS_WINDOWS
    202         pThis->Base.pfnGetMediaSize = drvHostFloppyGetMediaSize;
     201            pThis->Base.pfnGetMediaSize = drvHostFloppyGetMediaSize;
    203202#endif
    204203#ifdef RT_OS_LINUX
    205         pThis->Base.pfnPoll         = drvHostFloppyPoll;
    206         pThis->Base.pfnGetMediaSize = drvHostFloppyGetMediaSize;
     204            pThis->Base.pfnPoll         = drvHostFloppyPoll;
     205            pThis->Base.pfnGetMediaSize = drvHostFloppyGetMediaSize;
    207206#endif
    208207
    209         /*
    210          * 2nd init part.
    211          */
    212         rc = DRVHostBaseInitFinish(&pThis->Base);
     208            /*
     209             * 2nd init part.
     210             */
     211            rc = DRVHostBaseInitFinish(&pThis->Base);
     212        }
     213        else
     214        {
     215            pThis->fAttachFailError = true;
     216            rc = VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
     217        }
    213218    }
    214219    if (RT_FAILURE(rc))
  • trunk/src/VBox/Devices/Storage/DrvMediaISO.cpp

    r44528 r45061  
    197197    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
    198198
    199     RTFileClose(pThis->hFile);
    200     pThis->hFile = NIL_RTFILE;
     199    if (pThis->hFile != NIL_RTFILE)
     200    {
     201        RTFileClose(pThis->hFile);
     202        pThis->hFile = NIL_RTFILE;
     203    }
    201204
    202205    if (pThis->pszFilename)
  • trunk/src/VBox/Devices/Storage/DrvRawImage.cpp

    r44528 r45061  
    235235    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
    236236
    237     RTFileClose(pThis->hFile);
    238     pThis->hFile = NIL_RTFILE;
     237    if (pThis->hFile != NIL_RTFILE)
     238    {
     239        RTFileClose(pThis->hFile);
     240        pThis->hFile = NIL_RTFILE;
     241    }
    239242
    240243    if (pThis->pszFilename)
  • trunk/src/VBox/Devices/Storage/DrvSCSI.cpp

    r44889 r45061  
    847847
    848848    /* Free the VSCSI device and LUN handle. */
    849     VSCSILUN hVScsiLun;
    850     int rc = VSCSIDeviceLunDetach(pThis->hVScsiDevice, 0, &hVScsiLun);
    851     AssertRC(rc);
    852 
    853     Assert(hVScsiLun == pThis->hVScsiLun);
    854     rc = VSCSILunDestroy(hVScsiLun);
    855     AssertRC(rc);
    856     rc = VSCSIDeviceDestroy(pThis->hVScsiDevice);
    857     AssertRC(rc);
     849    if (pThis->hVScsiDevice)
     850    {
     851        VSCSILUN hVScsiLun;
     852        int rc = VSCSIDeviceLunDetach(pThis->hVScsiDevice, 0, &hVScsiLun);
     853        AssertRC(rc);
     854
     855        Assert(hVScsiLun == pThis->hVScsiLun);
     856        rc = VSCSILunDestroy(hVScsiLun);
     857        AssertRC(rc);
     858        rc = VSCSIDeviceDestroy(pThis->hVScsiDevice);
     859        AssertRC(rc);
     860
     861        pThis->hVScsiDevice = NULL;
     862        pThis->hVScsiLun    = NULL;
     863    }
    858864}
    859865
     
    868874    PDRVSCSI pThis = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
    869875    LogFlowFunc(("pDrvIns=%#p pCfg=%#p\n", pDrvIns, pCfg));
    870 LogRelFunc(("pDrvIns=%#p pCfg=%#p\n", pDrvIns, pCfg));
    871876    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
    872877
  • trunk/src/VBox/Devices/Storage/DrvVD.cpp

    r44358 r45061  
    20692069static DECLCALLBACK(void) drvvdDestruct(PPDMDRVINS pDrvIns)
    20702070{
     2071    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
    20712072    PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
    20722073    LogFlowFunc(("\n"));
    2073     PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
    20742074
    20752075    RTSEMFASTMUTEX mutex;
     
    20882088    }
    20892089
    2090     if (VALID_PTR(pThis->pBlkCache))
     2090    if (RT_VALID_PTR(pThis->pBlkCache))
    20912091    {
    20922092        PDMR3BlkCacheRelease(pThis->pBlkCache);
     
    20942094    }
    20952095
    2096     if (VALID_PTR(pThis->pDisk))
     2096    if (RT_VALID_PTR(pThis->pDisk))
    20972097    {
    20982098        VDDestroy(pThis->pDisk);
     
    21082108    }
    21092109    if (pThis->pbData)
     2110    {
    21102111        RTMemFree(pThis->pbData);
     2112        pThis->pbData = NULL;
     2113    }
    21112114    if (pThis->pszBwGroup)
    21122115    {
     
    21212124 * @copydoc FNPDMDRVCONSTRUCT
    21222125 */
    2123 static DECLCALLBACK(int) drvvdConstruct(PPDMDRVINS pDrvIns,
    2124                                         PCFGMNODE pCfg,
    2125                                         uint32_t fFlags)
     2126static DECLCALLBACK(int) drvvdConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
    21262127{
    21272128    LogFlowFunc(("\n"));
     2129    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
    21282130    PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
    21292131    int rc = VINF_SUCCESS;
     
    21352137    bool fMaybeReadOnly;         /**< True if the media may or may not be read-only. */
    21362138    bool fHonorZeroWrites;       /**< True if zero blocks should be written. */
    2137     PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
    21382139
    21392140    /*
     
    21482149    pThis->fMergePending                = false;
    21492150    pThis->MergeCompleteMutex           = NIL_RTSEMFASTMUTEX;
     2151    pThis->MergeLock                    = NIL_RTSEMRW;
    21502152    pThis->uMergeSource                 = VD_LAST_IMAGE;
    21512153    pThis->uMergeTarget                 = VD_LAST_IMAGE;
     
    27392741    /* Open the cache image if set. */
    27402742    if (   RT_SUCCESS(rc)
    2741         && VALID_PTR(pszCachePath))
     2743        && RT_VALID_PTR(pszCachePath))
    27422744    {
    27432745        /* Insert the custom I/O interface only if we're told to use new IO.
     
    27722774    }
    27732775
    2774     if (VALID_PTR(pszCachePath))
     2776    if (RT_VALID_PTR(pszCachePath))
    27752777        MMR3HeapFree(pszCachePath);
    2776     if (VALID_PTR(pszCacheFormat))
     2778    if (RT_VALID_PTR(pszCacheFormat))
    27772779        MMR3HeapFree(pszCacheFormat);
    27782780
     
    28662868    if (RT_FAILURE(rc))
    28672869    {
    2868         if (VALID_PTR(pszName))
     2870        if (RT_VALID_PTR(pszName))
    28692871            MMR3HeapFree(pszName);
    2870         if (VALID_PTR(pszFormat))
     2872        if (RT_VALID_PTR(pszFormat))
    28712873            MMR3HeapFree(pszFormat);
    28722874        /* drvvdDestruct does the rest. */
  • trunk/src/VBox/VMM/VMMR3/PDMNetShaper.cpp

    r44528 r45061  
    346346    VM_ASSERT_EMT(pUVM->pVM);
    347347    AssertPtrReturn(pFilter, VERR_INVALID_POINTER);
     348    /* Now, return quietly if the filter isn't attached since driver/device
     349       destructors are called on constructor failure. */
     350    if (!pFilter->pBwGroupR3)
     351        return VINF_SUCCESS;
    348352    AssertPtrReturn(pFilter->pBwGroupR3, VERR_INVALID_POINTER);
    349353
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