From: Marcin Slusarz Date: Sun, 22 Jun 2008 12:11:40 +0000 (-0300) Subject: V4L/DVB (8100): V4L/vivi: fix possible memory leak in vivi_fillbuff X-Git-Tag: v2.6.26-rc9~91^2~1 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c554e6b984ce6b36488b93a7ec8e2752233e7cb;p=linux-2.6 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 Signed-off-by: Marcin Slusarz Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 845be1864f..5ff9a58b61 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++) {