[Nouveau] [PATCH] drm: sgdma: free allocated memory if TT init fails

Alexandre Courbot acourbot at nvidia.com
Wed Dec 10 10:37:17 PST 2014


When ttm_dma_tt_init() fails in nouveau_sgdma_create_ttm(), we should
free the previously allocated memory before returning NULL.

Signed-off-by: Alexandre Courbot <acourbot at nvidia.com>
---
 drm/nouveau_sgdma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drm/nouveau_sgdma.c b/drm/nouveau_sgdma.c
index 01707e7deaf5..e4fc494d688d 100644
--- a/drm/nouveau_sgdma.c
+++ b/drm/nouveau_sgdma.c
@@ -107,7 +107,10 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev,
 	else
 		nvbe->ttm.ttm.func = &nv50_sgdma_backend;
 
-	if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page))
+	if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page)) {
+		kfree(nvbe);
 		return NULL;
+	}
+
 	return &nvbe->ttm.ttm;
 }
-- 
2.1.3



More information about the Nouveau mailing list