diff mbox

drm, cirrus_fbdev: Fix leak in cirrusfb_create()

Message ID alpine.LNX.2.00.1207202039350.23164@swampdragon.chaosbits.net (mailing list archive)
State New, archived
Headers show

Commit Message

Jesper Juhl July 20, 2012, 6:47 p.m. UTC
We have this code:

...
	sysram = vmalloc(size);
	if (!sysram)
		return -ENOMEM;

	info = framebuffer_alloc(0, device);
	if (info == NULL)
		return -ENOMEM;
...

If the vmalloc() call succeeds but the framebuffer_alloc() call
subsequently fails then we'll leak the memory allocated for 'sysram'
with vmalloc().

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

Patch

diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 9a276a5..cdaa270 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -155,8 +155,10 @@  static int cirrusfb_create(struct cirrus_fbdev *gfbdev,
 		return -ENOMEM;
 
 	info = framebuffer_alloc(0, device);
-	if (info == NULL)
+	if (!info) {
+		vfree(sysram);
 		return -ENOMEM;
+	}
 
 	info->par = gfbdev;