mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mgag200: Fix a memory leak in mgag200fb_create()
@ 2012-06-21 22:13 Jesper Juhl
  2012-06-22  8:00 ` devendra.aaru
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2012-06-21 22:13 UTC (permalink / raw)
  To: Dave Airlie; +Cc: David Airlie, dri-devel, linux-kernel

First we allocate memory for 'sysram' with vmalloc() and subsequently
we allocate for 'info' with framebuffer_alloc(). If the second
allocation fails we return -ENOMEM, but neglect to vfree() the memory
we previously allocated for 'sysram', thus leaking it.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 drivers/gpu/drm/mgag200/mgag200_fb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c
index 880d336..3c837e5 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -156,8 +156,10 @@ static int mgag200fb_create(struct mga_fbdev *mfbdev,
 		return -ENOMEM;
 
 	info = framebuffer_alloc(0, device);
-	if (info == NULL)
+	if (info == NULL) {
+		vfree(sysram);
 		return -ENOMEM;
+	}
 
 	info->par = mfbdev;
 
-- 
1.7.11


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


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

end of thread, other threads:[~2012-06-24 18:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-21 22:13 [PATCH] mgag200: Fix a memory leak in mgag200fb_create() Jesper Juhl
2012-06-22  8:00 ` devendra.aaru
2012-06-24 18:28   ` Jesper Juhl

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

all inboxes | Powered by JetHome®