android: ion: add checking of returned page
authorJanghyuck Kim <janghyuck.kim@samsung.com>
Wed, 28 Feb 2018 08:11:52 +0000 (17:11 +0900)
committerSangwook Ju <sw.ju@samsung.com>
Mon, 14 May 2018 10:45:24 +0000 (19:45 +0900)
This patch added checking code to avoid invalid address access for cache
operation.
ion_page_pool_alloc_pages() might return NULL when alloc_pages() could
not get enough pages as requested order, especially in high-order case.

Change-Id: I7aa2bb08f32f523f5b76930b46c0f47d3457895b
Signed-off-by: Janghyuck Kim <janghyuck.kim@samsung.com>
drivers/staging/android/ion/ion_page_pool.c

index 52d9d53bf85c3d7c49dce1efa0552c18fc94c8cb..75997d653fab196d7221c4d24e16ee2fa853d31e 100644 (file)
@@ -98,7 +98,7 @@ struct page *ion_page_pool_alloc(struct ion_page_pool *pool, bool nozero)
 
        if (!page) {
                page = ion_page_pool_alloc_pages(pool, nozero);
-               if (!pool->cached)
+               if (page && !pool->cached)
                        __flush_dcache_area(page_to_virt(page),
                                            1 << (PAGE_SHIFT + pool->order));
        }