When ion_map_kernel is execute the system must allocate
an array large enough to hold a pointer to each page in
the buffer. If the buffer is very large and the system
memory has become very fragmented, there may not be
sufficient high order allocations available from kmalloc.
Use vmalloc instead.
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
[jstultz: modified patch to apply to staging directory]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
pgprot_t pgprot;
struct sg_table *table = buffer->priv_virt;
int npages = PAGE_ALIGN(buffer->size) / PAGE_SIZE;
- struct page **pages = kzalloc(sizeof(struct page *) * npages,
- GFP_KERNEL);
+ struct page **pages = vmalloc(sizeof(struct page *) * npages);
struct page **tmp = pages;
+ if (!pages)
+ return 0;
+
if (buffer->flags & ION_FLAG_CACHED)
pgprot = PAGE_KERNEL;
else
}
}
vaddr = vmap(pages, npages, VM_MAP, pgprot);
- kfree(pages);
+ vfree(pages);
return vaddr;
}