Skip to contentSkip to conversation

st: fix test of value range in st_set_options()

PATCH New Roel Kluin 1 participant 1 message Aug 25, 2009

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 st: fix test of value range in st_set_options()

value cannot logically be less than START and greater than BUFFERSIZE.

---
// vi drivers/scsi/st.h +215
#define EXTENDED_SENSE_START 18

// vi include/scsi/scsi_cmnd.h +105
#define SCSI_SENSE_BUFFERSIZE 96

drivers/scsi/st.c +1 -1
index b33d042..cb79e39 100644
@@ -2280,7 +2280,7 @@ static int st_set_options(struct scsi_tape *STp, long options)
 	} else if (code == MT_ST_SET_CLN) {
 		value = (options & ~MT_ST_OPTIONS) & 0xff;
 		if (value != 0 &&
-		    value < EXTENDED_SENSE_START && value >= SCSI_SENSE_BUFFERSIZE)
+		    value < EXTENDED_SENSE_START || value >= SCSI_SENSE_BUFFERSIZE)
 			return (-EINVAL);
 		STp->cln_mode = value;
 		STp->cln_sense_mask = (options >> 8) & 0xff;