aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libiscsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/libiscsi.c')
-rw-r--r--drivers/scsi/libiscsi.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index e11b23c641e2..d37048c96eab 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -260,7 +260,7 @@ static int iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
260 } 260 }
261 261
262 if (rhdr->cmd_status == SAM_STAT_CHECK_CONDITION) { 262 if (rhdr->cmd_status == SAM_STAT_CHECK_CONDITION) {
263 int senselen; 263 uint16_t senselen;
264 264
265 if (datalen < 2) { 265 if (datalen < 2) {
266invalid_datalen: 266invalid_datalen:
@@ -270,12 +270,12 @@ invalid_datalen:
270 goto out; 270 goto out;
271 } 271 }
272 272
273 senselen = (data[0] << 8) | data[1]; 273 senselen = be16_to_cpu(*(uint16_t *)data);
274 if (datalen < senselen) 274 if (datalen < senselen)
275 goto invalid_datalen; 275 goto invalid_datalen;
276 276
277 memcpy(sc->sense_buffer, data + 2, 277 memcpy(sc->sense_buffer, data + 2,
278 min(senselen, SCSI_SENSE_BUFFERSIZE)); 278 min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE));
279 debug_scsi("copied %d bytes of sense\n", 279 debug_scsi("copied %d bytes of sense\n",
280 min(senselen, SCSI_SENSE_BUFFERSIZE)); 280 min(senselen, SCSI_SENSE_BUFFERSIZE));
281 } 281 }