From faf01bc3a5456dbb8cec918eed38b83dfd3d2e19 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Tue, 16 Dec 2008 12:17:29 -0800 Subject: [PATCH] --- yaml --- r: 123205 b: refs/heads/master c: a5ddde4a558b3bd1e3dc50e274a0db2ea7a8fd06 h: refs/heads/master i: 123203: cb958c32296adc7ff9c85a42435e664cdaf6dae9 v: v3 --- [refs] | 2 +- trunk/lib/swiotlb.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index ae952189b0e1..2a3ea7bc2f5d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0016fdee927f7aa0f428494bcf11ae60c7470a02 +refs/heads/master: a5ddde4a558b3bd1e3dc50e274a0db2ea7a8fd06 diff --git a/trunk/lib/swiotlb.c b/trunk/lib/swiotlb.c index db724ba7ebf6..1272b23e4769 100644 --- a/trunk/lib/swiotlb.c +++ b/trunk/lib/swiotlb.c @@ -301,6 +301,10 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir) start_dma_addr = virt_to_bus(io_tlb_start) & mask; offset_slots = ALIGN(start_dma_addr, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT; + + /* + * Carefully handle integer overflow which can occur when mask == ~0UL. + */ max_slots = mask + 1 ? ALIGN(mask + 1, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT : 1UL << (BITS_PER_LONG - IO_TLB_SHIFT);