All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: sgdma: free allocated memory if TT init fails
@ 2014-12-10 18:37 Alexandre Courbot
       [not found] ` <1418236637-15053-1-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Courbot @ 2014-12-10 18:37 UTC (permalink / raw)
  To: Ben Skeggs; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

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@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

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

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

end of thread, other threads:[~2014-12-10 22:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-10 18:37 [PATCH] drm: sgdma: free allocated memory if TT init fails Alexandre Courbot
     [not found] ` <1418236637-15053-1-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-12-10 18:47   ` Ilia Mirkin
     [not found]     ` <CAKb7UvgOwK469E6z_nEC+UHXVgs5d-6rNFiwiqApO63tbs2P6Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-12-10 18:58       ` Alexandre Courbot
     [not found]         ` <548897C2.8020401-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-12-10 22:07           ` Ben Skeggs

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.