diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2012-09-27 04:39:44 +0200 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2013-02-24 10:26:18 +0100 |
commit | 4d24834dfd25f2dab5977241cd5a6662edde92f7 (patch) | |
tree | c6ab1936fcef076629dd2c54bd076d58e8c75951 /include/scsi | |
parent | [SCSI] storvsc: Initialize the sglist (diff) | |
download | linux-4d24834dfd25f2dab5977241cd5a6662edde92f7.tar.xz linux-4d24834dfd25f2dab5977241cd5a6662edde92f7.zip |
[SCSI] Fix range check in scsi_host_dif_capable()
The range checking from fe542396 was bad. We would still end up walking
beyond the array as Type 3 is defined to be 4 in the protection
bitmask. Instead use ARRAY_SIZE() for the range check.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'include/scsi')
-rw-r--r-- | include/scsi/scsi_host.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 49084807eb6b..2b6956e9853d 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -873,7 +873,7 @@ static inline unsigned int scsi_host_dif_capable(struct Scsi_Host *shost, unsign SHOST_DIF_TYPE2_PROTECTION, SHOST_DIF_TYPE3_PROTECTION }; - if (target_type > SHOST_DIF_TYPE3_PROTECTION) + if (target_type >= ARRAY_SIZE(cap)) return 0; return shost->prot_capabilities & cap[target_type] ? target_type : 0; @@ -887,7 +887,7 @@ static inline unsigned int scsi_host_dix_capable(struct Scsi_Host *shost, unsign SHOST_DIX_TYPE2_PROTECTION, SHOST_DIX_TYPE3_PROTECTION }; - if (target_type > SHOST_DIX_TYPE3_PROTECTION) + if (target_type >= ARRAY_SIZE(cap)) return 0; return shost->prot_capabilities & cap[target_type]; |