arm: dma-mapping: fix off-by-one error in bitmap size check 82/42682/2
authorMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 1 Jul 2015 13:33:03 +0000 (15:33 +0200)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 1 Jul 2015 13:33:03 +0000 (15:33 +0200)
nr_bitmaps member of mapping structure stores the number of already
allocated bitmaps and it is interpreted as loop iterator (it starts from
0 not from 1), so a comparison against number of possible bitmap
extensions should include this fact. This patch fixes this by changing
the extension failure condition.

Reported-by: Hyungwon Hwang <human.hwang@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: Id929785a802790c9ab8500a50cd2496ab69545eb

arch/arm/mm/dma-mapping.c

index c27447653903f1134594fe309dc885285ea43bb3..40c05a8c6fc3b59013b388bf41095412843084cc 100644 (file)
@@ -1919,7 +1919,7 @@ static int extend_iommu_mapping(struct dma_iommu_mapping *mapping)
 {
        int next_bitmap;
 
-       if (mapping->nr_bitmaps > mapping->extensions)
+       if (mapping->nr_bitmaps >= mapping->extensions)
                return -EINVAL;
 
        next_bitmap = mapping->nr_bitmaps;