summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinayak Menon <vinmenon@codeaurora.org>2016-06-24 14:46:49 +0530
committerKyle Yan <kyan@codeaurora.org>2016-06-28 17:02:16 -0700
commit0806bdaa9adf5b095804b5cf6ef20488bfcce488 (patch)
tree45522b50f45568c9abf8a4439ca41044024a2581
parent226509c1ee0e257d2646fd4aec9a594f4c31dab0 (diff)
arm: dma-mapping: return NULL on remap error
Currently arm_dma_remap returns the offset value when it fails because of reasons like unavailability of vmalloc space. This is wrong as the caller expects NULL on failure, and can result in kernel panic on dereferencing the returned pointer. Change-Id: Ic851efecd1b5ff1c5e3105f28f392307857e63e3 Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
-rw-r--r--arch/arm/mm/dma-mapping.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 94d979205c83..bf6a92504175 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -789,13 +789,15 @@ static void *arm_dma_remap(struct device *dev, void *cpu_addr,
dma_addr_t handle, size_t size,
struct dma_attrs *attrs)
{
+ void *ptr;
struct page *page = pfn_to_page(dma_to_pfn(dev, handle));
pgprot_t prot = __get_dma_pgprot(attrs, PAGE_KERNEL);
unsigned long offset = handle & ~PAGE_MASK;
size = PAGE_ALIGN(size + offset);
- return __dma_alloc_remap(page, size, GFP_KERNEL, prot,
- __builtin_return_address(0)) + offset;
+ ptr = __dma_alloc_remap(page, size, GFP_KERNEL, prot,
+ __builtin_return_address(0));
+ return ptr ? ptr + offset : ptr;
}
static void arm_dma_unremap(struct device *dev, void *remapped_addr,