mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] V4L/vivi: fix possible memory leak in vivi_fillbuff
@ 2008-06-22  9:11 Marcin Slusarz
  0 siblings, 0 replies; only message in thread
From: Marcin Slusarz @ 2008-06-22  9:11 UTC (permalink / raw)
  To: LKML; +Cc: Daniel Marjamäki, Mauro Carvalho Chehab, video4linux-list

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

Noticed-by: Daniel Marjamäki <danielm77@spray.se>
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
---
 drivers/media/video/vivi.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 845be18..5ff9a58 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++) {
-- 
1.5.4.5


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-06-22  9:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-22  9:11 [PATCH] V4L/vivi: fix possible memory leak in vivi_fillbuff Marcin Slusarz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®