aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mps/mps_sas.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/mps/mps_sas.c')
-rw-r--r--sys/dev/mps/mps_sas.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/dev/mps/mps_sas.c b/sys/dev/mps/mps_sas.c
index 2aa4773eef91..fb4e224ed3b7 100644
--- a/sys/dev/mps/mps_sas.c
+++ b/sys/dev/mps/mps_sas.c
@@ -1490,7 +1490,6 @@ mpssas_scsiio_complete(struct mps_softc *sc, struct mps_command *cm)
MPI2_SCSI_IO_REPLY *rep;
union ccb *ccb;
struct mpssas_softc *sassc;
- u_int sense_len;
int dir = 0;
mps_dprint(sc, MPS_TRACE, "%s\n", __func__);
@@ -1666,10 +1665,16 @@ mpssas_scsiio_complete(struct mps_softc *sc, struct mps_command *cm)
}
if (rep->SCSIState & MPI2_SCSI_STATE_AUTOSENSE_VALID) {
- sense_len = MIN(rep->SenseCount,
- sizeof(struct scsi_sense_data));
- if (sense_len < rep->SenseCount)
- ccb->csio.sense_resid = rep->SenseCount - sense_len;
+ int sense_len;
+
+ if (rep->SenseCount < ccb->csio.sense_len)
+ ccb->csio.sense_resid = ccb->csio.sense_len -
+ rep->SenseCount;
+ else
+ ccb->csio.sense_resid = 0;
+
+ sense_len = min(rep->SenseCount, ccb->csio.sense_len -
+ ccb->csio.sense_resid);
bcopy(cm->cm_sense, &ccb->csio.sense_data, sense_len);
ccb->ccb_h.status |= CAM_AUTOSNS_VALID;
}