- Subject: [PATCH] ARM: dma-mapping: fix calculation of iova bitmap size
- From: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
- Date: Fri, 09 Mar 2012 15:53:32 +0100
- Cc: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>, Kyungmin Park <kyungmin.park@xxxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, Joerg Roedel <joro@xxxxxxxxxx>, Russell King - ARM Linux <linux@xxxxxxxxxxxxxxxx>, Chunsang Jeong <chunsang.jeong@xxxxxxxxxx>, Krishna Reddy <vdumpa@xxxxxxxxxx>, KyongHo Cho <pullip.cho@xxxxxxxxxxx>, Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>, Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, Hiroshi Doyu <hdoyu@xxxxxxxxxx>
- In-reply-to: <011701ccfc83$78030180$68090480$%szyprowski@samsung.com>
- References: <011701ccfc83$78030180$68090480$%szyprowski@samsung.com>
Fix calculation of iova address space for IOMMU-aware dma mapping.
Reported-by: Krishna Reddy <vdumpa@xxxxxxxxxx>
Signed-off-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
---
arch/arm/mm/dma-mapping.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index ea5a0ad..f0f600a 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1601,11 +1601,14 @@ struct dma_iommu_mapping *
arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size,
int order)
{
- unsigned int count = (size >> PAGE_SHIFT) - order;
+ unsigned int count = size >> (PAGE_SHIFT + order);
unsigned int bitmap_size = BITS_TO_LONGS(count) * sizeof(long);
struct dma_iommu_mapping *mapping;
int err = -ENOMEM;
+ if (!count)
+ return ERR_PTR(-EINVAL);
+
mapping = kzalloc(sizeof(struct dma_iommu_mapping), GFP_KERNEL);
if (!mapping)
goto err;
--
1.7.1.569.g6f426
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Home]
[Linux USB Devel]
[Video for Linux]
[Linux Audio Users]
[Photo]
[Yosemite News]
[Yosemite Photos]
[Video Projectors]
[PDAs]
[Free Online Dating]
[Hacking TiVo]
[Linux Kernel]
[Linux SCSI]
[XFree86]
[Devices]
[Big List of Linux Books]
[16.7MP]