]> err.no Git - linux-2.6/commitdiff
V4L/DVB (8100): V4L/vivi: fix possible memory leak in vivi_fillbuff
authorMarcin Slusarz <marcin.slusarz@gmail.com>
Sun, 22 Jun 2008 12:11:40 +0000 (09:11 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Thu, 26 Jun 2008 18:58:58 +0000 (15:58 -0300)
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

index 845be1864f685a01fad3a225bc9826ab09d61985..5ff9a58b6135b98b8644af14d042cc31cc824a5a 100644 (file)
@@ -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++) {