ion: ion_system_heap: Fix null pointer dereference

The pointer returned from alloc_pages passed unchecked to
ion_pages_sync_for_device.
This patch checks the return for NULL.

Change-Id: I407efc73a1e1297f382a7926cc79542bde88d06d
Fixes: 2d4fdc7bde ("ion: Fix DMA operations for ARM64")
Signed-off-by: Prakash Gupta <guptap@codeaurora.org>
This commit is contained in:
Prakash Gupta 2017-03-22 18:52:45 +05:30
parent 630218f710
commit aadb9ac89c

View file

@ -2,7 +2,7 @@
* drivers/staging/android/ion/ion_system_heap.c
*
* Copyright (C) 2011 Google, Inc.
* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@ -123,7 +123,9 @@ static struct page *alloc_buffer_page(struct ion_system_heap *heap,
gfp_t gfp_mask = low_order_gfp_flags;
if (order)
gfp_mask = high_order_gfp_flags;
page = alloc_pages(gfp_mask, order);
if (page)
ion_pages_sync_for_device(dev, page, PAGE_SIZE << order,
DMA_BIDIRECTIONAL);
}