V4L/DVB (8100): V4L/vivi: fix possible memory leak in vivi_fillbuff

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Sunday, June 29, 2008 - 1:06 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=5c554e...
Commit:     5c554e6b984ce6b36488b93a7ec8e2752233e7cb
Parent:     e470d8177ed6ae56f4310ce793a57bcb2fed1749
Author:     Marcin Slusarz <marcin.slusarz@gmail.com>
AuthorDate: Sun Jun 22 09:11:40 2008 -0300
Committer:  Mauro Carvalho Chehab <mchehab@infradead.org>
CommitDate: Thu Jun 26 15:58:58 2008 -0300

    V4L/DVB (8100): V4L/vivi: fix possible memory leak in vivi_fillbuff
    
    Move allocation after first check and fix memory leak.
    
    Noticed-by: Daniel Marjamäki <danielm77@spray.se>
    
    Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
---
 drivers/media/video/vivi.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 845be18..5ff9a58 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -327,13 +327,14 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf)
 	int hmax  = buf->vb.height;
 	int wmax  = buf->vb.width;
 	struct timeval ts;
-	char *tmpbuf = kmalloc(wmax * 2, GFP_ATOMIC);
+	char *tmpbuf;
 	void *vbuf = videobuf_to_vmalloc(&buf->vb);
 
-	if (!tmpbuf)
+	if (!vbuf)
 		return;
 
-	if (!vbuf)
+	tmpbuf = kmalloc(wmax * 2, GFP_ATOMIC);
+	if (!tmpbuf)
 		return;
 
 	for (h = 0; h < hmax; h++) {
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
V4L/DVB (8100): V4L/vivi: fix possible memory leak in vivi ..., Linux Kernel Mailing ..., (Sun Jun 29, 1:06 pm)