[PATCH] drm, cirrus_fbdev: Fix leak in cirrusfb_create()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
---
 drivers/gpu/drm/cirrus/cirrus_fbdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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;
 
-- 
1.7.11.2


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

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux