Commit 9835db39 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Greg Kroah-Hartman

scsi_common: do not clobber fixed sense information

commit ba083116 upstream.

For fixed sense the information field is 32 bits, to we need to truncate
the information field to avoid clobbering the sense code.

Fixes: a1524f22 ("libata-eh: Set 'information' field for autosense")
Signed-off-by: default avatarHannes Reinecke <hare@suse.com>
Reviewed-by: default avatarLee Duncan <lduncan@suse.com>
Reviewed-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: default avatarEwan D. Milne <emilne@redhat.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4cd4ebbd
...@@ -278,8 +278,16 @@ int scsi_set_sense_information(u8 *buf, int buf_len, u64 info) ...@@ -278,8 +278,16 @@ int scsi_set_sense_information(u8 *buf, int buf_len, u64 info)
ucp[3] = 0; ucp[3] = 0;
put_unaligned_be64(info, &ucp[4]); put_unaligned_be64(info, &ucp[4]);
} else if ((buf[0] & 0x7f) == 0x70) { } else if ((buf[0] & 0x7f) == 0x70) {
/*
* Only set the 'VALID' bit if we can represent the value
* correctly; otherwise just fill out the lower bytes and
* clear the 'VALID' flag.
*/
if (info <= 0xffffffffUL)
buf[0] |= 0x80; buf[0] |= 0x80;
put_unaligned_be64(info, &buf[3]); else
buf[0] &= 0x7f;
put_unaligned_be32((u32)info, &buf[3]);
} }
return 0; return 0;
......
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