Skip to contentSkip to conversation

dma-pool: turn the end variable in cma_in_zone into a u64

PATCH New Christoph Hellwig 1 participant 1 message Aug 27, 2020 DMA mapping helpers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-pool: turn the end variable in cma_in_zone into a u64

phys_addr_t can be 32-bit, in which case smatch will complain:

kernel/dma/pool.c:79 cma_in_zone() warn: always true condition '(end <= ((((32) == 64)) ?~0:((1 << (32)) - 1))) => (0-u32max <= u32max)'

Just turn the variable into a u64 to make the range check valid.

Fixes d7e673ec2c8e ("dma-pool: Only allocate from CMA when in same memory zone")
---
 kernel/dma/pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/dma/pool.c +1 -1
index 1281c0f0442bc5..b59325bad8edda 100644
@@ -60,7 +60,7 @@ static void dma_atomic_pool_size_add(gfp_t gfp, size_t size)
 static bool cma_in_zone(gfp_t gfp)
 {
 	unsigned long size;
-	phys_addr_t end;
+	u64 end;
 	struct cma *cma;
 
 	cma = dev_get_cma_area(NULL);
Signature · 6 lines
2.28.0

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu