All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Rankin <rankincj@yahoo.com>
To: linux-media@vger.kernel.org
Subject: Fwd: em28xx leaks
Date: Sat, 28 Jan 2012 12:31:16 +0000	[thread overview]
Message-ID: <4F23EA94.9080004@yahoo.com> (raw)
In-Reply-To: <4F22F94E.4010605@ct0.com>

Subject: em28xx leaks
Date: Fri, 27 Jan 2012 13:21:50 -0600
From: Todd Squires <squirest@ct0.com>
Organisation: Core Technologies
To: rankincj@yahoo.com

Hi Chris,

I've recently started using an em28xx, and have run into a memory
leak in the 3.2.1 kernel.

Poking around the Internet, I found that you've been recently
submitting patches for this driver.

I have a program which opens a V4L2 device, configures it, reads a
frame, then closes the device and exits. This program runs every
minute or so. After a short time, I noticed my Linux machine
complaining that vmalloc was out of memory.

Digging into the driver, I found the problem is in em28xx_v4l2_close.

Specifically, this test is not succeeding, and videobuf_stop is
not being called when it should be:

if (res_check(fh, EM28XX_RESOURCE_VIDEO)) {
	videobuf_stop(&fh->vb_vidq);
	res_free(fh, EM28XX_RESOURCE_VIDEO);
}

After failing to call videobuf_stop, em28xx_v4l2_close
then calls this:

videobuf_mmap_free(&fh->vb_vidq);

and it fails to deallocate because it sees "fh->vb_vidq.reading" is
still set. This leaks lots of memory.

I hacked around the problem by sticking this in the code:

if (fh->vb_vidq.reading)
	videobuf_read_stop(&fh->vb_vidq);

However, the proper fix is to go through the code and work out
why EM28XX_RESOURCE_VIDEO is not getting set as it should be.

Since I'm not terribly familiar with the driver, I figured I'd point
this issue out to you. If you can fix it, please let me know.
Otherwise I'll dig deeper and take care of it properly on my end
when I get some free time.

Cheers,

-Todd

           reply	other threads:[~2012-01-28 12:31 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <4F22F94E.4010605@ct0.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F23EA94.9080004@yahoo.com \
    --to=rankincj@yahoo.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.