Skip to content

Commit 4599d78

Browse files
keesjoergroedel
authored andcommitted
iommu/vt-d: Use correctly sized arguments for bit field
The find.h APIs are designed to be used only on unsigned long arguments. This can technically result in a over-read, but it is harmless in this case. Regardless, fix it to avoid the warning seen under -Warray-bounds, which we'd like to enable globally: In file included from ./include/linux/bitmap.h:9, from drivers/iommu/intel/iommu.c:17: drivers/iommu/intel/iommu.c: In function 'domain_context_mapping_one': ./include/linux/find.h:119:37: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'int[1]' [-Warray-bounds] 119 | unsigned long val = *addr & GENMASK(size - 1, 0); | ^~~~~ drivers/iommu/intel/iommu.c:2115:18: note: while referencing 'max_pde' 2115 | int pds, max_pde; | ^~~~~~~ Signed-off-by: Kees Cook <[email protected]> Acked-by: Yury Norov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 0fcfb00 commit 4599d78

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,10 +2112,10 @@ static void domain_exit(struct dmar_domain *domain)
21122112
*/
21132113
static inline unsigned long context_get_sm_pds(struct pasid_table *table)
21142114
{
2115-
int pds, max_pde;
2115+
unsigned long pds, max_pde;
21162116

21172117
max_pde = table->max_pasid >> PASID_PDE_SHIFT;
2118-
pds = find_first_bit((unsigned long *)&max_pde, MAX_NR_PASID_BITS);
2118+
pds = find_first_bit(&max_pde, MAX_NR_PASID_BITS);
21192119
if (pds < 7)
21202120
return 0;
21212121

0 commit comments

Comments
 (0)