aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/swiotlb.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index db724ba7ebf6..1272b23e4769 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -301,6 +301,10 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir)
301 start_dma_addr = virt_to_bus(io_tlb_start) & mask; 301 start_dma_addr = virt_to_bus(io_tlb_start) & mask;
302 302
303 offset_slots = ALIGN(start_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT; 303 offset_slots = ALIGN(start_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
304
305 /*
306 * Carefully handle integer overflow which can occur when mask == ~0UL.
307 */
304 max_slots = mask + 1 308 max_slots = mask + 1
305 ? ALIGN(mask + 1, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT 309 ? ALIGN(mask + 1, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT
306 : 1UL << (BITS_PER_LONG - IO_TLB_SHIFT); 310 : 1UL << (BITS_PER_LONG - IO_TLB_SHIFT);