From patchwork Fri Feb 8 10:47:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 14695 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 9AB9C23E0D for ; Fri, 8 Feb 2013 10:48:17 +0000 (UTC) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by fiordland.canonical.com (Postfix) with ESMTP id 34602A1940D for ; Fri, 8 Feb 2013 10:48:17 +0000 (UTC) Received: by mail-ve0-f182.google.com with SMTP id ox1so3194939veb.27 for ; Fri, 08 Feb 2013 02:48:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-auditid:from:to:date:message-id:x-mailer :x-brightmail-tracker:cc:subject:x-beenthere:x-mailman-version :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-gm-message-state; bh=LtjhUwX5hVgN+I9s6OvCyPPBLtCnGuo/cJj2NqCrzZk=; b=IqBZQwLSAEONRG/xvwbwyZ0Wkpmsho4wMTMBwbxnOccUkMnm5dSQ7HyMyI3X/Hx2n/ WqQ3ziw7cRumWzZP9G07nHox6ru0zaQxzMRTsGIQfiehSyf0plxLSxYXoFhqARUeBBdo 8pyahJMZxjmgYH8a9u17RByAoB3uw9u3f12mrx6WM6ywXZrOPvBQrTOeU/9H7ua6NQBk 1cc7ANPpbOimFs74nu8kIuNHZNzNaULM1ZG3J7ONPjwKZjEmdZ3r+9bB8XGKx8cMHt6K 8pxijR7u0uutYa5Z2YIVqir1sVjXgy+M5m0ybdtcSbscHUfYw/7evlSlVxe66dHp+F5h T9vA== X-Received: by 10.52.21.146 with SMTP id v18mr5173651vde.79.1360320496671; Fri, 08 Feb 2013 02:48:16 -0800 (PST) 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.58.252.8 with SMTP id zo8csp139184vec; Fri, 8 Feb 2013 02:48:15 -0800 (PST) X-Received: by 10.204.8.71 with SMTP id g7mr1313099bkg.118.1360320495378; Fri, 08 Feb 2013 02:48:15 -0800 (PST) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id gz3si13036638bkc.40.2013.02.08.02.48.13; Fri, 08 Feb 2013 02:48:15 -0800 (PST) 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 Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1U3lV3-00048e-FJ; Fri, 08 Feb 2013 10:48:09 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1U3lV0-00048Z-PH for linaro-mm-sig@lists.linaro.org; Fri, 08 Feb 2013 10:48:07 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MHW007BCE00TG00@mailout1.samsung.com> for linaro-mm-sig@lists.linaro.org; Fri, 08 Feb 2013 19:48:03 +0900 (KST) X-AuditID: cbfee61a-b7f7d6d000000f4e-9c-5114d7e3c4cd Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id E9.BF.03918.3E7D4115; Fri, 08 Feb 2013 19:48:03 +0900 (KST) Received: from localhost.localdomain ([106.116.147.30]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MHW009PWDZV5830@mmp1.samsung.com> for linaro-mm-sig@lists.linaro.org; Fri, 08 Feb 2013 19:48:03 +0900 (KST) From: Marek Szyprowski To: linux-arm-kernel@lists.infradead.org, linaro-mm-sig@lists.linaro.org Date: Fri, 08 Feb 2013 11:47:40 +0100 Message-id: <1360320460-17246-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNJMWRmVeSWpSXmKPExsVy+t9jAd3H10UCDf5+4bL4cuUhkwOjx+1/ j5kDGKO4bFJSczLLUov07RK4Ms6+X8xeMIe7YvfLDywNjFs4uxg5OSQETCR2PZnEAmGLSVy4 t56ti5GLQ0hgEaPE0s/7mCCcVUwSHV/aGUGq2AQMJbredrGB2CICHhJPVpxjBiliFrjMKPG2 4TszSEJYIEJi+fE17CA2i4CqxLPbK8BsXqCGbVNmANkcQOsUJOZMspnAyL2AkWEVo2hqQXJB cVJ6rqFecWJucWleul5yfu4mRrAXn0ntYFzZYHGIUYCDUYmHV+OscKAQa2JZcWXuIUYJDmYl EV7mXSKBQrwpiZVVqUX58UWlOanFhxilOViUxHkZTz0JEBJITyxJzU5NLUgtgskycXBKNTD6 3t/tc4kpPqL0Xtops89WHU+N0o7VWIuHlfxo3TC72qerY79y6iGmvLnHBReueRL9b/WWmXNd T12/3pd9Wfv6jLrGN/GdzV78t7/++2byPtFFOSGhnc15yZ1lFvxTnk+oubtV38b8aYS06k8J vWJdvVi2r2GHw/172ScHnDVw9PUR+r52k58SS3FGoqEWc1FxIgBAj6b83gEAAA== Cc: Kyungmin Park , Russell King - ARM Linux , Arnd Bergmann Subject: [Linaro-mm-sig] [PATCH] ARM: DMA-mapping: fix memory leak in IOMMU dma-mapping implementation 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: , MIME-Version: 1.0 Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQkglOuP3fwQp6qET+sO/SzugsAJSvVg64l0tAb2HLioLzrb8R4iF8BWJ9hW5LMzsbZmofQ+ This patch removes page_address() usage in IOMMU-aware dma-mapping implementation and replaced it with direct use of the cpu virtual address provided by the caller. page_address() returned incorrect address for pages remapped in atomic pool, what caused memory leak. Reported-by: Hiroshi Doyu Signed-off-by: Marek Szyprowski Tested-by: Hiroshi Doyu --- arch/arm/mm/dma-mapping.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 6b2fb87..8c38378 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1255,11 +1255,11 @@ err_mapping: return NULL; } -static void __iommu_free_atomic(struct device *dev, struct page **pages, +static void __iommu_free_atomic(struct device *dev, void *cpu_addr, dma_addr_t handle, size_t size) { __iommu_remove_mapping(dev, handle, size); - __free_from_pool(page_address(pages[0]), size); + __free_from_pool(cpu_addr, size); } static void *arm_iommu_alloc_attrs(struct device *dev, size_t size, @@ -1342,7 +1342,7 @@ void arm_iommu_free_attrs(struct device *dev, size_t size, void *cpu_addr, } if (__in_atomic_pool(cpu_addr, size)) { - __iommu_free_atomic(dev, pages, handle, size); + __iommu_free_atomic(dev, cpu_addr, handle, size); return; }