From patchwork Fri Jul 27 15:18:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 1249971 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id D649ADFFBF for ; Fri, 27 Jul 2012 15:25:45 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SumJp-0000xN-P2; Fri, 27 Jul 2012 15:19:09 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SumJk-0000wk-BI for linux-arm-kernel@lists.infradead.org; Fri, 27 Jul 2012 15:19:04 +0000 Received: from epcpsbgm2.samsung.com (mailout2.samsung.com [203.254.224.25]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M7T00LHYRUCGUA0@mailout2.samsung.com> for linux-arm-kernel@lists.infradead.org; Sat, 28 Jul 2012 00:18:57 +0900 (KST) X-AuditID: cbfee61b-b7f566d000005c8a-97-5012b160734d Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id E9.03.23690.061B2105; Sat, 28 Jul 2012 00:18:56 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M7T00LEERV6SY90@mmp1.samsung.com> for linux-arm-kernel@lists.infradead.org; Sat, 28 Jul 2012 00:18:56 +0900 (KST) From: Marek Szyprowski To: linux-arm-kernel@lists.infradead.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH] ARM: DMA-mapping: fix error path for memory allocation failure Date: Fri, 27 Jul 2012 17:18:34 +0200 Message-id: <1343402314-15678-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.10 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFJMWRmVeSWpSXmKPExsVy+t9jAd2EjUIBBus/WlhsenyN1YHRY/OS +gDGKC6blNSczLLUIn27BK6MmStb2QrWsFXsObSErYFxAWsXIyeHhICJxL2jR5ggbDGJC/fW s3UxcnEICSxilHj86DErhLOZSWJi439mkCo2AUOJrrddbCC2iICHxJMV55hBipgFFjNLvPuw jLGLkYNDWMBf4sjDOpAaFgFViZsze1lAbF6g+uXvpzJDbJOXeHq/j20CI/cCRoZVjKKpBckF xUnpuUZ6xYm5xaV56XrJ+bmbGME+fCa9g3FVg8UhRgEORiUe3hkiQgFCrIllxZW5hxglOJiV RHi1VwGFeFMSK6tSi/Lji0pzUosPMUpzsCiJ85p4f/UXEkhPLEnNTk0tSC2CyTJxcEo1MFps WDjlLT+jxYW9CrfOhj6ct/9zd9aR7RovTLglt8lcOi5pMyfJ2Ej2jO9s9pL5HVe634VphLtH 7Va9tL9wgchDxXus4vcsGW8JxqnsdmefZJY6oat3EiuD8GneCcnvG9f5/+OZL/T98IrmrBWv 78gx87l1ryidcfbxn6lXrOIzzZ5KnWmZK6DEUpyRaKjFXFScCAB6Islk3QEAAA== X-TM-AS-MML: No X-Spam-Note: CRM114 invocation failed X-Spam-Note: SpamAssassin invocation failed Cc: Abhinav Kochhar , Russell King - ARM Linux , Arnd Bergmann , Chunsang Jeong , Kyungmin Park , Subash Patel , Hiroshi Doyu , Sumit Semwal , Marek Szyprowski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch fixes incorrect check in error path. When the allocation of first page fails, the kernel ops appears due to accessing -1 element of the pages array. Reported-by: Sylwester Nawrocki Signed-off-by: Marek Szyprowski --- arch/arm/mm/dma-mapping.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 7a1d224..3096ed2 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -977,7 +977,7 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, gfp_t return pages; error: - while (--i) + while (i--) if (pages[i]) __free_pages(pages[i], 0); if (array_size <= PAGE_SIZE)