summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2017-01-05 11:35:10 +0000
committermav <mav@FreeBSD.org>2017-01-05 11:35:10 +0000
commit7f2989fc69c800f097704cd6189fa75d4dba9183 (patch)
tree4441be85d48753f8623903e28fdba4bb9a111b57
parent8176e7f302a8d7527da9b9d51b1f1cb31642b934 (diff)
downloadFreeBSD-src-7f2989fc69c800f097704cd6189fa75d4dba9183.zip
FreeBSD-src-7f2989fc69c800f097704cd6189fa75d4dba9183.tar.gz
MFC r310284:
When writing fixed format sense data, set VALID bit only if provided value for INFORMATION field fit into available 4 bytes (has no non-zero bytes except last 4), as explicitly required by SPC-5 specification.
-rw-r--r--sys/cam/scsi/scsi_all.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c
index 995090c..3d5c323 100644
--- a/sys/cam/scsi/scsi_all.c
+++ b/sys/cam/scsi/scsi_all.c
@@ -4019,11 +4019,17 @@ scsi_set_sense_data_va(struct scsi_sense_data *sense_data,
data_dest = &sense->info[0];
len_to_copy = MIN(sense_len,
sizeof(sense->info));
- /*
- * We're setting the info field, so
- * set the valid bit.
- */
- sense->error_code |= SSD_ERRCODE_VALID;
+
+ /* Set VALID bit only if no overflow. */
+ for (i = 0; i < sense_len - len_to_copy;
+ i++) {
+ if (data[i] != 0)
+ break;
+ }
+ if (i >= sense_len - len_to_copy) {
+ sense->error_code |=
+ SSD_ERRCODE_VALID;
+ }
}
/*
OpenPOWER on IntegriCloud