aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/ctl_tpc.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2016-05-10 08:37:41 +0000
committerAlexander Motin <mav@FreeBSD.org>2016-05-10 08:37:41 +0000
commit8fadf66094b765fe5da11accb918e9c74721ed67 (patch)
tree9d50e8fd296549d14b9401182e9bd2e6c8f09da0 /sys/cam/ctl/ctl_tpc.c
parent38618bf430ddf96ee1e9e4caaf2d40cd48b1f767 (diff)
downloadsrc-8fadf66094b765fe5da11accb918e9c74721ed67.tar.gz
src-8fadf66094b765fe5da11accb918e9c74721ed67.zip
Fix previous commit to report proper error code.
MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=299348
Diffstat (limited to 'sys/cam/ctl/ctl_tpc.c')
-rw-r--r--sys/cam/ctl/ctl_tpc.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/sys/cam/ctl/ctl_tpc.c b/sys/cam/ctl/ctl_tpc.c
index 19d0277acfc7..bebaccff6315 100644
--- a/sys/cam/ctl/ctl_tpc.c
+++ b/sys/cam/ctl/ctl_tpc.c
@@ -1104,11 +1104,11 @@ tpc_ranges_length(struct scsi_range_desc *range, int nrange)
}
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 *range, int nrange, uint64_t maxlba)
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 *ctsio)
}
/* 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 *ctsio)
*/
/* 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);