VirtualBox

Ignore:
Timestamp:
Nov 4, 2022 2:23:26 PM (2 years ago)
Author:
vboxsync
Message:

Devices/DevVirtioSCSI: Fix reference counting issue where a reference would've been released twice in the I/O request finish handler when the underlying driver reported a CHECK CONDITION error for the request causing the VM to hang when powering off, ticketref:21144 [build fix]

File:
1 edited

Legend:

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

    r97400 r97402  
    847847 * @param   pDevIns     The device instance.
    848848 * @param   pThis       VirtIO SCSI shared instance data.
    849  * @param   pThisCC     VirtIO SCSI ring-3 instance data.
    850849 * @param   uVirtqNbr        Virtq index
    851850 * @param   pVirtqBuf  Pointer to pre-processed descriptor chain pulled from virtq
     
    856855 * @returns VINF_SUCCESS
    857856 */
    858 static int virtioScsiR3ReqErr(PPDMDEVINS pDevIns, PVIRTIOSCSI pThis, PVIRTIOSCSICC pThisCC, uint16_t uVirtqNbr,
     857static int virtioScsiR3ReqErr(PPDMDEVINS pDevIns, PVIRTIOSCSI pThis, uint16_t uVirtqNbr,
    859858                              PVIRTQBUF pVirtqBuf, REQ_RESP_HDR_T *pRespHdr, uint8_t *pbSense,
    860859                              size_t cbSenseCfg)
     
    905904 * @param   pDevIns     The device instance.
    906905 * @param   pThis       VirtIO SCSI shared instance data.
    907  * @param   pThisCC     VirtIO SCSI ring-3 instance data.
    908906 * @param   uVirtqNbr   Virtq index
    909907 * @param   pVirtqBuf   Pointer to pre-processed descriptor chain pulled from virtq
     
    917915 * @returns VINF_SUCCESS
    918916 */
    919 static int virtioScsiR3ReqErr4(PPDMDEVINS pDevIns, PVIRTIOSCSI pThis, PVIRTIOSCSICC pThisCC, uint16_t uVirtqNbr,
     917static int virtioScsiR3ReqErr4(PPDMDEVINS pDevIns, PVIRTIOSCSI pThis, uint16_t uVirtqNbr,
    920918                               PVIRTQBUF pVirtqBuf, size_t cbResidual, uint8_t bStatus, uint8_t bResponse,
    921919                               uint8_t *pbSense, size_t cbSense, size_t cbSenseCfg)
     
    928926    RespHdr.uResponse        = bResponse;
    929927
    930     return virtioScsiR3ReqErr(pDevIns, pThis, pThisCC, uVirtqNbr, pVirtqBuf, &RespHdr, pbSense, cbSenseCfg);
     928    return virtioScsiR3ReqErr(pDevIns, pThis, uVirtqNbr, pVirtqBuf, &RespHdr, pbSense, cbSenseCfg);
    931929}
    932930
     
    10501048        respHdr.uResidual  = pReq->cbDataIn & UINT32_MAX;
    10511049
    1052         virtioScsiR3ReqErr(pDevIns, pThis, pThisCC, pReq->uVirtqNbr, pReq->pVirtqBuf, &respHdr, abSense,
     1050        virtioScsiR3ReqErr(pDevIns, pThis, pReq->uVirtqNbr, pReq->pVirtqBuf, &respHdr, abSense,
    10531051                           RT_MIN(pThis->virtioScsiConfig.uSenseSize, VIRTIOSCSI_SENSE_SIZE_MAX));
    10541052    }
     
    12601258    {
    12611259        Log2Func(("Error submitting request, bad LUN format\n"));
    1262         return virtioScsiR3ReqErr4(pDevIns, pThis, pThisCC, uVirtqNbr, pVirtqBuf, cbDataIn + cbDataOut, 0 /*bStatus*/,
     1260        return virtioScsiR3ReqErr4(pDevIns, pThis, uVirtqNbr, pVirtqBuf, cbDataIn + cbDataOut, 0 /*bStatus*/,
    12631261                                   VIRTIOSCSI_S_FAILURE, NULL /*pbSense*/, 0 /*cbSense*/, cbSenseCfg);
    12641262    }
     
    12751273                              0, SCSI_SENSE_ILLEGAL_REQUEST,
    12761274                              0, 0, 0, 0, 10, SCSI_ASC_LOGICAL_UNIT_NOT_SUPPORTED, 0, 0 };
    1277         return virtioScsiR3ReqErr4(pDevIns, pThis, pThisCC, uVirtqNbr, pVirtqBuf, cbDataIn + cbDataOut, SCSI_STATUS_CHECK_CONDITION,
     1275        return virtioScsiR3ReqErr4(pDevIns, pThis, uVirtqNbr, pVirtqBuf, cbDataIn + cbDataOut, SCSI_STATUS_CHECK_CONDITION,
    12781276                                   VIRTIOSCSI_S_BAD_TARGET, abSense, sizeof(abSense), cbSenseCfg);
    12791277    }
     
    12861284                              0, SCSI_SENSE_ILLEGAL_REQUEST,
    12871285                              0, 0, 0, 0, 10, SCSI_ASC_LOGICAL_UNIT_NOT_SUPPORTED, 0, 0 };
    1288         return virtioScsiR3ReqErr4(pDevIns, pThis, pThisCC, uVirtqNbr, pVirtqBuf, cbDataIn + cbDataOut, SCSI_STATUS_CHECK_CONDITION,
     1286        return virtioScsiR3ReqErr4(pDevIns, pThis, uVirtqNbr, pVirtqBuf, cbDataIn + cbDataOut, SCSI_STATUS_CHECK_CONDITION,
    12891287                                   VIRTIOSCSI_S_OK, abSense, sizeof(abSense), cbSenseCfg);
    12901288    }
     
    12941292    {
    12951293        Log2Func(("Aborting req submission because reset is in progress\n"));
    1296         return virtioScsiR3ReqErr4(pDevIns, pThis, pThisCC, uVirtqNbr, pVirtqBuf, cbDataIn + cbDataOut, SCSI_STATUS_OK,
     1294        return virtioScsiR3ReqErr4(pDevIns, pThis, uVirtqNbr, pVirtqBuf, cbDataIn + cbDataOut, SCSI_STATUS_OK,
    12971295                                   VIRTIOSCSI_S_RESET, NULL /*pbSense*/, 0 /*cbSense*/, cbSenseCfg);
    12981296    }
     
    13061304        uint8_t abSense[] = { RT_BIT(7) | SCSI_SENSE_RESPONSE_CODE_CURR_FIXED,
    13071305                              0, SCSI_SENSE_ILLEGAL_REQUEST, 0, 0, 0, 0, 10, 0, 0, 0 };
    1308         return virtioScsiR3ReqErr4(pDevIns, pThis, pThisCC, uVirtqNbr, pVirtqBuf, cbDataIn + cbDataOut, SCSI_STATUS_CHECK_CONDITION,
     1306        return virtioScsiR3ReqErr4(pDevIns, pThis, uVirtqNbr, pVirtqBuf, cbDataIn + cbDataOut, SCSI_STATUS_CHECK_CONDITION,
    13091307                                   VIRTIOSCSI_S_FAILURE, abSense, sizeof(abSense), cbSenseCfg);
    13101308    }
     
    13771375        respHdr.uResponse  = VIRTIOSCSI_S_FAILURE;
    13781376        respHdr.uResidual  = (cbDataIn + cbDataOut) & UINT32_MAX;
    1379         virtioScsiR3ReqErr(pDevIns, pThis, pThisCC, uVirtqNbr, pVirtqBuf, &respHdr, abSense, cbSenseCfg);
     1377        virtioScsiR3ReqErr(pDevIns, pThis, uVirtqNbr, pVirtqBuf, &respHdr, abSense, cbSenseCfg);
    13801378        virtioScsiR3FreeReq(pTarget, pReq);
    13811379        virtioScsiR3Release(pDevIns, pThis, pThisCC);
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