aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/common
diff options
context:
space:
mode:
authorJohann Friedrichs <johann.friedrichs@web.de>2009-10-07 03:41:37 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-05 15:41:04 -0500
commit311c70e1f906b7411b30f526ef15deb62cb37e7a (patch)
tree8e73c017a4dccc69fbe229cfc9f5980b4867bc06 /drivers/media/common
parent622b828ab795580903e79acb33fb44f5c9ce7b0f (diff)
V4L/DVB (13239): saa7146: fix memory leakage in pagetable-handling
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> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/common')
-rw-r--r--drivers/media/common/saa7146_video.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 552dab442d78..becbaadb3b77 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,
1205 return 0; 1205 return 0;
1206} 1206}
1207 1207
1208static void release_all_pagetables(struct saa7146_dev *dev, struct saa7146_buf *buf)
1209{
1210 saa7146_pgtable_free(dev->pci, &buf->pt[0]);
1211 saa7146_pgtable_free(dev->pci, &buf->pt[1]);
1212 saa7146_pgtable_free(dev->pci, &buf->pt[2]);
1213}
1214
1208static int buffer_prepare(struct videobuf_queue *q, 1215static int buffer_prepare(struct videobuf_queue *q,
1209 struct videobuf_buffer *vb, enum v4l2_field field) 1216 struct videobuf_buffer *vb, enum v4l2_field field)
1210{ 1217{
@@ -1257,16 +1264,12 @@ static int buffer_prepare(struct videobuf_queue *q,
1257 1264
1258 sfmt = format_by_fourcc(dev,buf->fmt->pixelformat); 1265 sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
1259 1266
1267 release_all_pagetables(dev, buf);
1260 if( 0 != IS_PLANAR(sfmt->trans)) { 1268 if( 0 != IS_PLANAR(sfmt->trans)) {
1261 saa7146_pgtable_free(dev->pci, &buf->pt[0]);
1262 saa7146_pgtable_free(dev->pci, &buf->pt[1]);
1263 saa7146_pgtable_free(dev->pci, &buf->pt[2]);
1264
1265 saa7146_pgtable_alloc(dev->pci, &buf->pt[0]); 1269 saa7146_pgtable_alloc(dev->pci, &buf->pt[0]);
1266 saa7146_pgtable_alloc(dev->pci, &buf->pt[1]); 1270 saa7146_pgtable_alloc(dev->pci, &buf->pt[1]);
1267 saa7146_pgtable_alloc(dev->pci, &buf->pt[2]); 1271 saa7146_pgtable_alloc(dev->pci, &buf->pt[2]);
1268 } else { 1272 } else {
1269 saa7146_pgtable_free(dev->pci, &buf->pt[0]);
1270 saa7146_pgtable_alloc(dev->pci, &buf->pt[0]); 1273 saa7146_pgtable_alloc(dev->pci, &buf->pt[0]);
1271 } 1274 }
1272 1275
@@ -1329,6 +1332,9 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
1329 struct saa7146_buf *buf = (struct saa7146_buf *)vb; 1332 struct saa7146_buf *buf = (struct saa7146_buf *)vb;
1330 1333
1331 DEB_CAP(("vbuf:%p\n",vb)); 1334 DEB_CAP(("vbuf:%p\n",vb));
1335
1336 release_all_pagetables(dev, buf);
1337
1332 saa7146_dma_free(dev,q,buf); 1338 saa7146_dma_free(dev,q,buf);
1333} 1339}
1334 1340