From patchwork Wed Oct 7 07:41:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Hunold X-Patchwork-Id: 52173 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n977mBXu003412 for ; Wed, 7 Oct 2009 07:48:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932383AbZJGHmR (ORCPT ); Wed, 7 Oct 2009 03:42:17 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932367AbZJGHmR (ORCPT ); Wed, 7 Oct 2009 03:42:17 -0400 Received: from bar.sig21.net ([80.81.252.164]:47802 "EHLO bar.sig21.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932304AbZJGHmQ (ORCPT ); Wed, 7 Oct 2009 03:42:16 -0400 Received: from p5489d0e8.dip.t-dialin.net ([84.137.208.232] helo=[192.168.1.105]) by bar.sig21.net with esmtpsa (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.63) (envelope-from ) id 1MvR9W-0007NU-6U; Wed, 07 Oct 2009 09:41:39 +0200 Message-ID: <4ACC4631.3040002@linuxtv.org> Date: Wed, 07 Oct 2009 09:41:37 +0200 From: Michael Hunold User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: linux-media@vger.kernel.org CC: Mauro Carvalho Chehab , johann.friedrichs@web.de Subject: [PATCH] saa7146 memory leakage in pagetable-handling, v2 X-Spam-21-Score: -2.3 (--) X-Spam-21-Report: No, score=-2.3 required=5.0 tests=ALL_TRUSTED=-1.8, AWL=0.216, BAYES_20=-0.74 autolearn=no Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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); }