Author: mav
Date: Thu Jan  5 11:35:10 2017
New Revision: 311415
URL: https://svnweb.freebsd.org/changeset/base/311415

Log:
  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.

Modified:
  stable/10/sys/cam/scsi/scsi_all.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/scsi/scsi_all.c
==============================================================================
--- stable/10/sys/cam/scsi/scsi_all.c   Thu Jan  5 11:34:30 2017        
(r311414)
+++ stable/10/sys/cam/scsi/scsi_all.c   Thu Jan  5 11:35:10 2017        
(r311415)
@@ -4019,11 +4019,17 @@ scsi_set_sense_data_va(struct scsi_sense
                                        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;
+                                       }
                                }
 
                                /*
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to