Commit 0d04df9b authored by Eric Moore's avatar Eric Moore Committed by James Bottomley

[SCSI] mpt2sas : fix oops when firmware sends large sense buffer size

There is a bug in firmware where the reply message frame says there is a
16kb sense buffer, when in reality its only 20 bytes.  This fix insures
the memcpy action doesn't corrupte the memory beyond the 90 bytes allocated in
the scsi command for sense buffer.
Signed-off-by: default avatarEric Moore <eric.moore@lsi.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent 03ea1115
...@@ -2863,8 +2863,9 @@ scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply) ...@@ -2863,8 +2863,9 @@ scsih_io_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply)
struct sense_info data; struct sense_info data;
const void *sense_data = mpt2sas_base_get_sense_buffer(ioc, const void *sense_data = mpt2sas_base_get_sense_buffer(ioc,
smid); smid);
memcpy(scmd->sense_buffer, sense_data, u32 sz = min_t(u32, SCSI_SENSE_BUFFERSIZE,
le32_to_cpu(mpi_reply->SenseCount)); le32_to_cpu(mpi_reply->SenseCount));
memcpy(scmd->sense_buffer, sense_data, sz);
_scsih_normalize_sense(scmd->sense_buffer, &data); _scsih_normalize_sense(scmd->sense_buffer, &data);
/* failure prediction threshold exceeded */ /* failure prediction threshold exceeded */
if (data.asc == 0x5D) if (data.asc == 0x5D)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment