public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL
@ 2016-03-07  9:21 Zhen Lei
  2016-03-07 10:43 ` Leizhen (ThunderTown)
  2016-03-07 11:41 ` One Thousand Gnomes
  0 siblings, 2 replies; 6+ messages in thread
From: Zhen Lei @ 2016-03-07  9:21 UTC (permalink / raw)
  To: Andrew Morton, Marek Szyprowski, Will Deacon, linux-kernel
  Cc: Zefan Li, Xinwei Hu, Tianhong Ding, Hanjun Guo, Zhen Lei

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-03-08  1:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-07  9:21 [PATCH 1/1] dma-mapping: to avoid exception when cpu_addr is NULL Zhen Lei
2016-03-07 10:43 ` Leizhen (ThunderTown)
2016-03-07 22:59   ` Andrew Morton
2016-03-08  1:32     ` Leizhen (ThunderTown)
2016-03-07 11:41 ` One Thousand Gnomes
2016-03-07 12:22   ` Leizhen (ThunderTown)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox