From: Michael Hunold <hunold@linuxtv.org>
To: linux-media@vger.kernel.org
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>, johann.friedrichs@web.de
Subject: [PATCH] saa7146 memory leakage in pagetable-handling, v2
Date: Wed, 07 Oct 2009 09:41:37 +0200 [thread overview]
Message-ID: <4ACC4631.3040002@linuxtv.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 443 bytes --]
Hello Mauro,
on Mon, 28 Sep 2009 Johann Friedrichs sent a patch to linux-media in
order to fix a memory leak in my saa7146 driver.
He contacted me and together we have come up with a new patch that fixes
the problem more explicitely.
Would you please be so kind and manually pick up this patch and provide
it upstream?
All kudos belong to Johann Friedrich for finding the bug and providing
the initial fix.
Best regards
Michael Hunold.
[-- Attachment #2: saa7146_fix_pagetables_memory_leak.diff --]
[-- Type: text/plain, Size: 2124 bytes --]
V4L: saa7146: fix memory leak when buffer properties change or buffer
is released
From: Johann Friedrichs <johann.friedrichs@web.de>
In buffer_release() the previously allocated pagetables are not
freed, which might result in a memory leak in certain application
use-cases, where the frame format is changed from planar format to
non-planar format. The fix explicitely frees the page tables when a
format change is done and when buffer_release() is called.
Signed-off-by: Johann Friedrichs <johann.friedrichs@web.de>
Signed-off-by: Michael Hunold <hunold@linuxtv.org>
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 552dab4..becbaad 100644
--- a/drivers/media/common/saa7146_video.c
+++ b/drivers/media/common/saa7146_video.c
@@ -1205,6 +1205,13 @@ static int buffer_activate (struct saa7146_dev *dev,
return 0;
}
+static void release_all_pagetables(struct saa7146_dev *dev, struct saa7146_buf *buf)
+{
+ saa7146_pgtable_free(dev->pci, &buf->pt[0]);
+ saa7146_pgtable_free(dev->pci, &buf->pt[1]);
+ saa7146_pgtable_free(dev->pci, &buf->pt[2]);
+}
+
static int buffer_prepare(struct videobuf_queue *q,
struct videobuf_buffer *vb, enum v4l2_field field)
{
@@ -1257,16 +1264,12 @@ static int buffer_prepare(struct videobuf_queue *q,
sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
+ release_all_pagetables(dev, buf);
if( 0 != IS_PLANAR(sfmt->trans)) {
- saa7146_pgtable_free(dev->pci, &buf->pt[0]);
- saa7146_pgtable_free(dev->pci, &buf->pt[1]);
- saa7146_pgtable_free(dev->pci, &buf->pt[2]);
-
saa7146_pgtable_alloc(dev->pci, &buf->pt[0]);
saa7146_pgtable_alloc(dev->pci, &buf->pt[1]);
saa7146_pgtable_alloc(dev->pci, &buf->pt[2]);
} else {
- saa7146_pgtable_free(dev->pci, &buf->pt[0]);
saa7146_pgtable_alloc(dev->pci, &buf->pt[0]);
}
@@ -1329,6 +1332,9 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
struct saa7146_buf *buf = (struct saa7146_buf *)vb;
DEB_CAP(("vbuf:%p\n",vb));
+
+ release_all_pagetables(dev, buf);
+
saa7146_dma_free(dev,q,buf);
}
next reply other threads:[~2009-10-07 7:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-07 7:41 Michael Hunold [this message]
2009-10-31 8:57 ` [PATCH] saa7146 memory leakage in pagetable-handling, v2 Mauro Carvalho Chehab
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=4ACC4631.3040002@linuxtv.org \
--to=hunold@linuxtv.org \
--cc=johann.friedrichs@web.de \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox