[COMMON] iommu/exynos: fix overflow check condition
authorJanghyuck Kim <janghyuck.kim@samsung.com>
Thu, 7 Jul 2016 14:01:16 +0000 (23:01 +0900)
committerSangwook Ju <sw.ju@samsung.com>
Mon, 14 May 2018 10:45:19 +0000 (19:45 +0900)
Considering 32bit dma address, overflow checking condition is fixed.

Change-Id: I98066be8a219f9a26e076b2f64285455f48d057d
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
drivers/iommu/exynos-iommu.c

index e847cbd19ff3c440f119e6a648c0ac32755dcc32..750c4b1e00722e596ff0b452faee56a70cce7ebc 100644 (file)
 #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);