Fix previous commit to report proper error code.

MFC after:	2 weeks
This commit is contained in:
Alexander Motin 2016-05-10 08:37:41 +00:00
parent 38618bf430
commit 8fadf66094

View File

@ -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);