Skip to contentSkip to conversation

off by one in FlashPoint.c

PATCH In review Dan Carpenter 2 participants 4 messages Dec 27, 2009 – Dec 28, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 off by one in FlashPoint.c

The check should be >= instead of > or we could go past the end of the array.

drivers/scsi/FlashPoint.c +1 -1
@@ -3924,7 +3924,7 @@
 {
 	struct sccb_mgr_tar_info *currTar_Info;
 
-	if ((p_sccb->TargID > MAX_SCSI_TAR) || (p_sccb->Lun > MAX_LUN)) {
+	if ((p_sccb->TargID >= MAX_SCSI_TAR) || (p_sccb->Lun > MAX_LUN)) {
 		return;
 	}
 	currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID];
#1 lore raw
Quoted 2 lines · Dan Carpenter

The check should be >= instead of > or we could go past the end of the array.

What about the LUN check? I'm not sure either way, but usually MAX LUN
is the max number of LUNs, not the max LU number, although that's been in flux lately.

Quoted 20 lines
drivers/scsi/FlashPoint.c +1 -2
@@ -3924,7 +3924,7 @@
 {
 	struct sccb_mgr_tar_info *currTar_Info;
 
-	if ((p_sccb->TargID > MAX_SCSI_TAR) || (p_sccb->Lun > MAX_LUN)) {
+	if ((p_sccb->TargID >= MAX_SCSI_TAR) || (p_sccb->Lun > MAX_LUN)) {
 		return;
 	}
 	currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID];
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 10 lines · Joe Eykholt
Quoted 2 lines · Dan Carpenter

The check should be >= instead of > or we could go past the end of the array.

What about the LUN check? I'm not sure either way, but usually MAX LUN
is the max number of LUNs, not the max LU number, although that's been in flux lately.

No no. You're clearly correct. That matches how MAX_LUN is used throughout the file.

Will send an updated patch.

regards,
dan carpenter

Quoted 19 lines
Quoted 19 lines
drivers/scsi/FlashPoint.c +1 -1
@@ -3924,7 +3924,7 @@
 {
 	struct sccb_mgr_tar_info *currTar_Info;
 -	if ((p_sccb->TargID > MAX_SCSI_TAR) || (p_sccb->Lun > MAX_LUN)) {
+	if ((p_sccb->TargID >= MAX_SCSI_TAR) || (p_sccb->Lun > MAX_LUN)) {
 		return;
 	}
 	currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID];
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

PATCH 1/1 off by one in FlashPoint.c (v2)

In reply to Joe Eykholt

The check on MAX_SCSI_TAR should be >= instead of > or we could go past the end of the array.

Joe Eykholt aslo correctly points out that the check on MAX_LUN should be

Quoted 1 line

= as well. That matches with how it is used in the rest of the file.

drivers/scsi/FlashPoint.c +1 -1
@@ -3924,7 +3924,7 @@ static void FPT_sinits(struct sccb *p_sc
 {
 	struct sccb_mgr_tar_info *currTar_Info;
 
-	if ((p_sccb->TargID > MAX_SCSI_TAR) || (p_sccb->Lun > MAX_LUN)) {
+	if ((p_sccb->TargID >= MAX_SCSI_TAR) || (p_sccb->Lun >= MAX_LUN)) {
 		return;
 	}
 	currTar_Info = &FPT_sccbMgrTbl[p_card][p_sccb->TargID];