Commit 4d24834dfd25f2dab5977241cd5a6662edde92f7
Committed by
James Bottomley
1 parent
9d2696e658
Exists in
master
and in
20 other branches
[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>
Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff
include/scsi/scsi_host.h
... | ... | @@ -873,7 +873,7 @@ |
873 | 873 | SHOST_DIF_TYPE2_PROTECTION, |
874 | 874 | SHOST_DIF_TYPE3_PROTECTION }; |
875 | 875 | |
876 | - if (target_type > SHOST_DIF_TYPE3_PROTECTION) | |
876 | + if (target_type >= ARRAY_SIZE(cap)) | |
877 | 877 | return 0; |
878 | 878 | |
879 | 879 | return shost->prot_capabilities & cap[target_type] ? target_type : 0; |
... | ... | @@ -887,7 +887,7 @@ |
887 | 887 | SHOST_DIX_TYPE2_PROTECTION, |
888 | 888 | SHOST_DIX_TYPE3_PROTECTION }; |
889 | 889 | |
890 | - if (target_type > SHOST_DIX_TYPE3_PROTECTION) | |
890 | + if (target_type >= ARRAY_SIZE(cap)) | |
891 | 891 | return 0; |
892 | 892 | |
893 | 893 | return shost->prot_capabilities & cap[target_type]; |