From: Marek Szyprowski Date: Wed, 1 Jul 2015 13:33:03 +0000 (+0200) Subject: arm: dma-mapping: fix off-by-one error in bitmap size check X-Git-Tag: submit/tizen/20150706.105058~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=adde421ca55ea643ee740e4a2ca1908b74013a45;p=platform%2Fkernel%2Flinux-exynos.git arm: dma-mapping: fix off-by-one error in bitmap size check 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 Signed-off-by: Marek Szyprowski Change-Id: Id929785a802790c9ab8500a50cd2496ab69545eb --- diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index c27447653903..40c05a8c6fc3 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -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;