Skip to content

Commit 5c554e6

Browse files
mslusarzmchehab
authored andcommitted
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 <[email protected]> Signed-off-by: Marcin Slusarz <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent e470d81 commit 5c554e6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/media/video/vivi.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,14 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf)
327327
int hmax = buf->vb.height;
328328
int wmax = buf->vb.width;
329329
struct timeval ts;
330-
char *tmpbuf = kmalloc(wmax * 2, GFP_ATOMIC);
330+
char *tmpbuf;
331331
void *vbuf = videobuf_to_vmalloc(&buf->vb);
332332

333-
if (!tmpbuf)
333+
if (!vbuf)
334334
return;
335335

336-
if (!vbuf)
336+
tmpbuf = kmalloc(wmax * 2, GFP_ATOMIC);
337+
if (!tmpbuf)
337338
return;
338339

339340
for (h = 0; h < hmax; h++) {

0 commit comments

Comments
 (0)