浏览代码

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>
Marcin Slusarz 17 年之前
父节点
当前提交
5c554e6b98
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      drivers/media/video/vivi.c

+ 4 - 3
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 hmax  = buf->vb.height;
 	int wmax  = buf->vb.width;
 	int wmax  = buf->vb.width;
 	struct timeval ts;
 	struct timeval ts;
-	char *tmpbuf = kmalloc(wmax * 2, GFP_ATOMIC);
+	char *tmpbuf;
 	void *vbuf = videobuf_to_vmalloc(&buf->vb);
 	void *vbuf = videobuf_to_vmalloc(&buf->vb);
 
 
-	if (!tmpbuf)
+	if (!vbuf)
 		return;
 		return;
 
 
-	if (!vbuf)
+	tmpbuf = kmalloc(wmax * 2, GFP_ATOMIC);
+	if (!tmpbuf)
 		return;
 		return;
 
 
 	for (h = 0; h < hmax; h++) {
 	for (h = 0; h < hmax; h++) {