svn commit: r299348 - head/sys/cam/ctl

Alexander Motin mav at FreeBSD.org
Tue May 10 08:37:43 UTC 2016


Author: mav
Date: Tue May 10 08:37:41 2016
New Revision: 299348
URL: https://svnweb.freebsd.org/changeset/base/299348

Log:
  Fix previous commit to report proper error code.
  
  MFC after:	2 weeks

Modified:
  head/sys/cam/ctl/ctl_tpc.c

Modified: head/sys/cam/ctl/ctl_tpc.c
==============================================================================
--- head/sys/cam/ctl/ctl_tpc.c	Tue May 10 08:28:16 2016	(r299347)
+++ head/sys/cam/ctl/ctl_tpc.c	Tue May 10 08:37:41 2016	(r299348)
@@ -1104,11 +1104,11 @@ tpc_ranges_length(struct scsi_range_desc
 }
 
 static int
-tpc_check_ranges(struct scsi_range_desc *range, int nrange, uint64_t maxlba)
+tpc_check_ranges_l(struct scsi_range_desc *range, int nrange, uint64_t maxlba)
 {
-	uint64_t b1, b2;
-	uint32_t l1, l2;
-	int i, j;
+	uint64_t b1;
+	uint32_t l1;
+	int i;
 
 	for (i = 0; i < nrange; i++) {
 		b1 = scsi_8btou64(range[i].lba);
@@ -1116,6 +1116,16 @@ tpc_check_ranges(struct scsi_range_desc 
 		if (b1 + l1 < b1 || b1 + l1 > maxlba + 1)
 			return (-1);
 	}
+	return (0);
+}
+
+static int
+tpc_check_ranges_x(struct scsi_range_desc *range, int nrange)
+{
+	uint64_t b1, b2;
+	uint32_t l1, l2;
+	int i, j;
+
 	for (i = 0; i < nrange - 1; i++) {
 		b1 = scsi_8btou64(range[i].lba);
 		l1 = scsi_4btoul(range[i].length);
@@ -2019,10 +2029,16 @@ ctl_populate_token(struct ctl_scsiio *ct
 	}
 
 	/* Validate list of ranges */
-	if (tpc_check_ranges(&data->desc[0],
+	if (tpc_check_ranges_l(&data->desc[0],
 	    scsi_2btoul(data->range_descriptor_length) /
 	    sizeof(struct scsi_range_desc),
 	    lun->be_lun->maxlba) != 0) {
+		ctl_set_lba_out_of_range(ctsio);
+		goto done;
+	}
+	if (tpc_check_ranges_x(&data->desc[0],
+	    scsi_2btoul(data->range_descriptor_length) /
+	    sizeof(struct scsi_range_desc)) != 0) {
 		ctl_set_invalid_field(ctsio, /*sks_valid*/ 0,
 		    /*command*/ 0, /*field*/ 0, /*bit_valid*/ 0,
 		    /*bit*/ 0);
@@ -2161,10 +2177,16 @@ ctl_write_using_token(struct ctl_scsiio 
 */
 
 	/* Validate list of ranges */
-	if (tpc_check_ranges(&data->desc[0],
+	if (tpc_check_ranges_l(&data->desc[0],
 	    scsi_2btoul(data->range_descriptor_length) /
 	    sizeof(struct scsi_range_desc),
 	    lun->be_lun->maxlba) != 0) {
+		ctl_set_lba_out_of_range(ctsio);
+		goto done;
+	}
+	if (tpc_check_ranges_x(&data->desc[0],
+	    scsi_2btoul(data->range_descriptor_length) /
+	    sizeof(struct scsi_range_desc)) != 0) {
 		ctl_set_invalid_field(ctsio, /*sks_valid*/ 0,
 		    /*command*/ 0, /*field*/ 0, /*bit_valid*/ 0,
 		    /*bit*/ 0);


More information about the svn-src-head mailing list