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-Url: https://git.stricted.de/?a=commitdiff_plain;h=5c554e6b984ce6b36488b93a7ec8e2752233e7cb;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 845be1864f68..5ff9a58b6135 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++) {