Skip to contentSkip to conversation

V4L/vivi: fix possible memory leak in vivi_fillbuff

PATCH New Marcin Slusarz 1 participant 1 message Jun 22, 2008 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 V4L/vivi: fix possible memory leak in vivi_fillbuff

Move allocation after first check and fix memory leak.
http://bugzilla.kernel.org/show_bug.cgi?id=10659

---
 drivers/media/video/vivi.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
drivers/media/video/vivi.c +4 -3
index 845be18..5ff9a58 100644
@@ -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++) {
Signature · 1 line
1.5.4.5