summaryrefslogtreecommitdiffstats
path: root/lib/swiotlb.c
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2008-12-16 12:17:29 -0800
committerIngo Molnar <mingo@elte.hu>2008-12-17 18:57:02 +0100
commita5ddde4a558b3bd1e3dc50e274a0db2ea7a8fd06 (patch)
treee304335e81bc43942c00bb0d1c9f51f9286ebab6 /lib/swiotlb.c
parent0016fdee927f7aa0f428494bcf11ae60c7470a02 (diff)
downloadlinux-a5ddde4a558b3bd1e3dc50e274a0db2ea7a8fd06.tar.gz
linux-a5ddde4a558b3bd1e3dc50e274a0db2ea7a8fd06.tar.bz2
linux-a5ddde4a558b3bd1e3dc50e274a0db2ea7a8fd06.zip
swiotlb: add comment where we handle the overflow of a dma mask on 32 bit
Impact: cleanup Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'lib/swiotlb.c')
-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)
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);