linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers: dma-coherent: free memory when failed to init DMA memory pool
@ 2015-12-03 10:36 Fugang Duan
  2015-12-03 12:50 ` Michal Nazarewicz
  0 siblings, 1 reply; 8+ messages in thread
From: Fugang Duan @ 2015-12-03 10:36 UTC (permalink / raw)
  To: linux-arm-kernel

Free dma coherent memory when it failed to init DMA memory pool after
calling .dma_init_coherent_memory(), otherwise it causes memmory leak.

Signed-off-by: Fugang Duan <B38611@freescale.com>
---
 drivers/base/dma-coherent.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index 55b8398..beb6bbe 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -286,6 +286,7 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
 				     &mem) != DMA_MEMORY_MAP) {
 		pr_err("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n",
 			&rmem->base, (unsigned long)rmem->size / SZ_1M);
+		kfree(mem);
 		return -ENODEV;
 	}
 	rmem->priv = mem;
-- 
1.9.1

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

end of thread, other threads:[~2015-12-04  2:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-03 10:36 [PATCH] drivers: dma-coherent: free memory when failed to init DMA memory pool Fugang Duan
2015-12-03 12:50 ` Michal Nazarewicz
2015-12-03 13:54   ` Duan Andy
2015-12-03 14:32     ` Michal Nazarewicz
2015-12-03 15:39     ` Russell King - ARM Linux
2015-12-03 16:22       ` Michal Nazarewicz
2015-12-04  2:18         ` Duan Andy
2015-12-04  2:20       ` Duan Andy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).