mm/ioremap: check virtual address alignment while creating huge mappings
[linux-2.6-microblaze.git] / lib / ioremap.c
index 0632136..a95161d 100644 (file)
@@ -86,6 +86,9 @@ static int ioremap_try_huge_pmd(pmd_t *pmd, unsigned long addr,
        if ((end - addr) != PMD_SIZE)
                return 0;
 
+       if (!IS_ALIGNED(addr, PMD_SIZE))
+               return 0;
+
        if (!IS_ALIGNED(phys_addr, PMD_SIZE))
                return 0;
 
@@ -126,6 +129,9 @@ static int ioremap_try_huge_pud(pud_t *pud, unsigned long addr,
        if ((end - addr) != PUD_SIZE)
                return 0;
 
+       if (!IS_ALIGNED(addr, PUD_SIZE))
+               return 0;
+
        if (!IS_ALIGNED(phys_addr, PUD_SIZE))
                return 0;
 
@@ -166,6 +172,9 @@ static int ioremap_try_huge_p4d(p4d_t *p4d, unsigned long addr,
        if ((end - addr) != P4D_SIZE)
                return 0;
 
+       if (!IS_ALIGNED(addr, P4D_SIZE))
+               return 0;
+
        if (!IS_ALIGNED(phys_addr, P4D_SIZE))
                return 0;