From 518ecce0e466ad5d84dc04f60b393b7bc7671146 Mon Sep 17 00:00:00 2001 From: Janghyuck Kim Date: Thu, 7 Jul 2016 23:01:16 +0900 Subject: [PATCH] [COMMON] iommu/exynos: fix overflow check condition Considering 32bit dma address, overflow checking condition is fixed. Change-Id: I98066be8a219f9a26e076b2f64285455f48d057d Signed-off-by: Janghyuck Kim --- drivers/iommu/exynos-iommu.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index e847cbd19ff3..750c4b1e0072 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -33,9 +33,10 @@ #include "exynos-iommu.h" /* Default IOVA region: [0x1000000, 0xD0000000) */ -#define IOVA_START 0x10000000 -#define IOVA_END 0xD0000000 -#define IOVA_OVFL(x) ((x) > 0xFFFFFFFF) +#define IOVA_START 0x10000000 +#define IOVA_END 0xD0000000 +#define IOVA_OVFL(addr, size) ((((addr) + (size)) > 0xFFFFFFFF) || \ + ((addr) + (size) < (addr))) static struct kmem_cache *lv2table_kmem_cache; @@ -1468,7 +1469,7 @@ static int __init exynos_iommu_create_domain(void) ret = of_get_dma_window(domain_np, NULL, 0, NULL, &d_addr, &d_size); if (!ret) { - if (d_addr == 0 || IOVA_OVFL(d_addr + d_size)) { + if (d_addr == 0 || IOVA_OVFL(d_addr, d_size)) { pr_err("Failed to get valid dma ranges,\n"); pr_err("Domain %s, range %pad++%#zx]\n", domain_np->name, &d_addr, d_size); -- 2.20.1