[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20190705114826.28586-1-lecopzer.chen@mediatek.com>
Date: Fri, 5 Jul 2019 19:48:26 +0800
From: Lecopzer Chen <lecopzer.chen@...iatek.com>
To: <linux-mm@...ck.org>
CC: Lecopzer Chen <lecopzer.chen@...iatek.com>,
Mark-PK Tsai <Mark-PK.Tsai@...iatek.com>,
YJ Chiang <yj.chiang@...iatek.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Pavel Tatashin <pasha.tatashin@...cle.com>,
Oscar Salvador <osalvador@...e.de>,
Michal Hocko <mhocko@...e.com>,
Mike Rapoport <rppt@...ux.ibm.com>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH] mm/sparse: fix ALIGN() without power of 2 in sparse_buffer_alloc()
The size argumnet passed into sparse_buffer_alloc() has already
aligned with PAGE_SIZE or PMD_SIZE.
If the size after aligned is not power of 2 (e.g. 0x480000), the
PTR_ALIGN() will return wrong value.
Use roundup to round sparsemap_buf up to next multiple of size.
Signed-off-by: Lecopzer Chen <lecopzer.chen@...iatek.com>
Signed-off-by: Mark-PK Tsai <Mark-PK.Tsai@...iatek.com>
Cc: YJ Chiang <yj.chiang@...iatek.com>
Cc: Lecopzer Chen <lecopzer.chen@...iatek.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Pavel Tatashin <pasha.tatashin@...cle.com>
Cc: Oscar Salvador <osalvador@...e.de>
Cc: Michal Hocko <mhocko@...e.com>
Cc: Mike Rapoport <rppt@...ux.ibm.com>
Cc: linux-kernel@...r.kernel.org
---
mm/sparse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/sparse.c b/mm/sparse.c
index 2b3b5be85120..dafd130f9a55 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -459,7 +459,7 @@ void * __meminit sparse_buffer_alloc(unsigned long size)
void *ptr = NULL;
if (sparsemap_buf) {
- ptr = PTR_ALIGN(sparsemap_buf, size);
+ ptr = (void *) roundup((unsigned long)sparsemap_buf, size);
if (ptr + size > sparsemap_buf_end)
ptr = NULL;
else {
--
2.18.0
Powered by blists - more mailing lists