lkml.org 
[lkml]   [2016]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL
Date
Do this to keep consistent with kfree, which tolerate ptr is NULL.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
include/linux/dma-mapping.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 75857cd..fdd4294 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -402,7 +402,10 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_handle)
{
- return dma_free_attrs(dev, size, cpu_addr, dma_handle, NULL);
+ if (unlikely(!cpu_addr))
+ return;
+
+ dma_free_attrs(dev, size, cpu_addr, dma_handle, NULL);
}

static inline void *dma_alloc_noncoherent(struct device *dev, size_t size,
--
2.5.0

\
 
 \ /
  Last update: 2016-03-07 11:01    [W:0.039 / U:0.732 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site