win-pvdrivers

changeset 971:6c6def3fb1ca

Fix sense overrun error
author James Harper <james.harper@bendigoit.com.au>
date Sun Apr 08 10:41:09 2012 +1000 (2012-04-08)
parents a473ca2d1eac
children ef1f25e2c281
files xenscsi/xenscsi.c
line diff
     1.1 --- a/xenscsi/xenscsi.c	Sat Jan 14 23:34:51 2012 +1100
     1.2 +++ b/xenscsi/xenscsi.c	Sun Apr 08 10:41:09 2012 +1000
     1.3 @@ -700,10 +700,12 @@ XenScsi_HwScsiStartIo(PVOID DeviceExtens
     1.4        PXENSCSI_LU_DATA lud = ScsiPortGetLogicalUnit(DeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun);
     1.5        if (lud != NULL && lud->sense_len)
     1.6        {
     1.7 +        int i;
     1.8          KdPrint((__DRIVER_NAME "     Emulating REQUEST_SENSE (lu data = %p)\n", lud));
     1.9          memcpy(Srb->DataBuffer, lud->sense_buffer, min(lud->sense_len, Srb->DataTransferLength));
    1.10 -        if (lud->sense_len < Srb->DataTransferLength)
    1.11 +        if (lud->sense_len > Srb->DataTransferLength)
    1.12          {
    1.13 +          KdPrint((__DRIVER_NAME "     Sense overrun Srb->DataTransferLength = %d, lud->sense_len = %d\n", Srb->DataTransferLength, lud->sense_len));
    1.14            Srb->DataTransferLength = lud->sense_len;
    1.15            Srb->SrbStatus = SRB_STATUS_DATA_OVERRUN;
    1.16          }
    1.17 @@ -711,8 +713,8 @@ XenScsi_HwScsiStartIo(PVOID DeviceExtens
    1.18          {
    1.19            Srb->SrbStatus = SRB_STATUS_SUCCESS;
    1.20          }
    1.21 -        //for (i = 0; i < Srb->DataTransferLength; i++)
    1.22 -        //  KdPrint((__DRIVER_NAME "     sense %02x: %02x\n", i, (ULONG)((PUCHAR)Srb->DataBuffer)[i]));
    1.23 +        for (i = 0; i < min(lud->sense_len, 8); i++)
    1.24 +          KdPrint((__DRIVER_NAME "     sense %02x: %02x\n", i, (ULONG)((PUCHAR)lud->sense_buffer)[i]));
    1.25          lud->sense_len = 0;
    1.26          ScsiPortNotification(RequestComplete, DeviceExtension, Srb);
    1.27          ScsiPortNotification(NextRequest, DeviceExtension);