mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
mm/sparse.c: fix ALIGN() without power of 2 in sparse_buffer_alloc()
The size argument passed into sparse_buffer_alloc() has already been 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. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Lecopzer Chen <[email protected]> Signed-off-by: Mark-PK Tsai <[email protected]> Cc: YJ Chiang <[email protected]> Cc: Lecopzer Chen <[email protected]> Cc: Pavel Tatashin <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Rapoport <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
ae83189405
commit
db57e98d87
1 changed files with 1 additions and 1 deletions
|
|
@ -501,7 +501,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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue