From patchwork Tue Sep 4 21:42:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Peethambaran X-Patchwork-Id: 11174 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B032A23F27 for ; Tue, 4 Sep 2012 21:43:10 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id D9BB7A192DD for ; Tue, 4 Sep 2012 21:42:18 +0000 (UTC) Received: by ieak11 with SMTP id k11so5684531iea.11 for ; Tue, 04 Sep 2012 14:43:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :dkim-signature:mime-version:date:message-id:from:to:subject :x-beenthere:x-mailman-version:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:content-type :content-transfer-encoding:sender:errors-to:x-gm-message-state; bh=ReeJcvYcQ7M7lEoVa+EMRXPIaiak+zOEmP9ivoXjfnA=; b=m9raeaOTBQ8Hv+DEZbk3TttJaN7OKQ1D5KgxTxoV4fGMab9N7XrHUlEc5XuYkbK2pX tNv7gh/RRz5TdlXKbmoND8m9Eer30hTtFLT3IY8bsrhWNzCAQeH+6uquxb4miXi9wpdA MstwrHhYd0k8im05MwGaukMkzKehzKKmiirjQb9qpRn7MJSCi4ZLAE+d3UOf/3GTC21p LgNYrx1oYjbkhVUKG27BtImCry9UCwkTEUYRDLzT2oqXnv11FP5MR4Zl2kB7rdEtFiar R8SBK/oc8aS0OUwP7k7BApuMpX7NiK/rb6Zjq6776yYo9uQJK6UVheNLc74Iu0W5sYL+ 2MIA== Received: by 10.50.160.228 with SMTP id xn4mr15964317igb.1.1346794989544; Tue, 04 Sep 2012 14:43:09 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp215888igc; Tue, 4 Sep 2012 14:43:08 -0700 (PDT) Received: by 10.216.49.6 with SMTP id w6mr12486335web.207.1346794987529; Tue, 04 Sep 2012 14:43:07 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id j18si31545885wiv.29.2012.09.04.14.43.06; Tue, 04 Sep 2012 14:43:07 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@gmail.com Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T90tf-0001fI-Tg; Tue, 04 Sep 2012 21:43:02 +0000 Received: from mail-bk0-f42.google.com ([209.85.214.42]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T90tD-0001aw-2I for linaro-mm-sig@lists.linaro.org; Tue, 04 Sep 2012 21:42:54 +0000 Received: by bkcjm19 with SMTP id jm19so4884674bkc.1 for ; Tue, 04 Sep 2012 14:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=n4Qz3s8/PmFNBMjKiebnNYtAGoCEHIIkvTcH0Ict8lc=; b=l14eVkP+5bCVrPacVtSD3duGDPyL3BHVp/KU0Q9yU0nbzfPKHJRI+nNFHyt8q4t7Rw OevWV8JDl+bWqxZZ7Uie9sEPnl6WRlaVH6HAD2Jg0ZC57IMCb+p4+oXb7xEKwDxJ6Cux B17uK8YRI9xawQnap02Z8EqFbG+yRSZQBYGejAy9wJENGqXWPvb1q2oQqMZhFOwTJz6r NUoNWQ4OabTmLToiYGIHnzEbLNiQtRi2BU4uS83wwwATOUXLnGf7ov0xMzLiESzMXQIN ZdhFK9og4DH9NNpwAghOeldMpdyC6gOF1a3mKRBoUbs7xfJXgv9nykZ5v7MIa+bZDrwR z34g== MIME-Version: 1.0 Received: by 10.204.157.146 with SMTP id b18mr8604245bkx.108.1346794950727; Tue, 04 Sep 2012 14:42:30 -0700 (PDT) Received: by 10.204.169.199 with HTTP; Tue, 4 Sep 2012 14:42:30 -0700 (PDT) Date: Wed, 5 Sep 2012 03:12:30 +0530 Message-ID: From: Nishanth Peethambaran To: linaro-mm-sig@lists.linaro.org, Rebecca Zavin , Zhangfei Gao , Haojian Zhuang Subject: [Linaro-mm-sig] [PATCH 2/2] gpu: ion: Fix a memory leak X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQmaaypHKZ2XfhpHhMe2Xwayg+3oVN+16qRgkK1ppiCF9QNaF89tPpzMqpxsHlIvbczsxgXU >From 03184abb0efd05a422c4525f2f4398f127a9a0c9 Mon Sep 17 00:00:00 2001 From: Nishanth Peethambaran Date: Wed, 5 Sep 2012 02:49:30 +0530 Subject: [PATCH 2/2] gpu: ion: Fix a memory leak The dirty bitmap buffer for cached buffers is freed when buffer gets destroyed. Change-Id: If2b6a6e3ffc5ed57623cfcbc01cb6b720bee532f Signed-off-by: Nishanth Peethambaran --- drivers/gpu/ion/ion.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) buffer->dev = dev; @@ -210,6 +212,8 @@ static void ion_buffer_destroy(struct kref *kref) if (WARN_ON(buffer->kmap_cnt > 0)) buffer->heap->ops->unmap_kernel(buffer->heap, buffer); + if (buffer->flags & ION_FLAG_CACHED) + kfree(buffer->dirty); buffer->heap->ops->unmap_dma(buffer->heap, buffer); buffer->heap->ops->free(buffer); mutex_lock(&dev->lock); diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c index 207d00f..3ad766a 100644 --- a/drivers/gpu/ion/ion.c +++ b/drivers/gpu/ion/ion.c @@ -176,12 +176,14 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, return ERR_PTR(-EINVAL); } - ret = ion_buffer_alloc_dirty(buffer); - if (ret) { - heap->ops->unmap_dma(heap, buffer); - heap->ops->free(buffer); - kfree(buffer); - return ERR_PTR(ret); + if (buffer->flags & ION_FLAG_CACHED) { + ret = ion_buffer_alloc_dirty(buffer); + if (ret) { + heap->ops->unmap_dma(heap, buffer); + heap->ops->free(buffer); + kfree(buffer); + return ERR_PTR(ret); + } }