From patchwork Wed Feb 11 09:01:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 5811551 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BB96ABF440 for ; Wed, 11 Feb 2015 09:31:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F119D20218 for ; Wed, 11 Feb 2015 09:31:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA8852008F for ; Wed, 11 Feb 2015 09:31:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YLTan-00053C-AR; Wed, 11 Feb 2015 09:28:21 +0000 Received: from mail-pa0-x22d.google.com ([2607:f8b0:400e:c03::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YLTFW-0001GT-O8 for linux-arm-kernel@lists.infradead.org; Wed, 11 Feb 2015 09:06:24 +0000 Received: by mail-pa0-f45.google.com with SMTP id et14so2747564pad.4 for ; Wed, 11 Feb 2015 01:06:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=LgHdYLA4Dkwd1uwbsHzP/bhABA+Fw0x7yG10kDNmZeo=; b=WjZBFetV2ulx/B8kwIRdkW05QCD3qUIZRlAQLcDPm9Yol9UNo+vL+5+TURBq4g5WUF db+zpghLAWXidZT5K6SO2wNIF8ZF6LX2pZUi77stQqmLgfiGJaKeLBvVYq+XPODxkZvc 24+zEz0OT3A/wRlPugVyu0A2YzhpX780rjCEhmBUtyxumoT4FhXM2OqXobVSRasJv+d3 FYZH4TcQEAbIW0G/7zdEz0cnCrX5sVJ3JTVDiKoBUwvs+OxY3ekj4GFzzbei1ymt4fic mdb3qz1BNhoJagbH5Qn8DyB/TsSexMqsayBNoLEjP25G8J3DNti+jLVpLrtvLQACeCWT zYkg== X-Received: by 10.68.226.69 with SMTP id rq5mr45071808pbc.116.1423645560519; Wed, 11 Feb 2015 01:06:00 -0800 (PST) Received: from aramis.localdomain (softbank126010191003.bbtec.net. [126.10.191.3]) by mx.google.com with ESMTPSA id mm9sm208732pbc.76.2015.02.11.01.05.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Feb 2015 01:05:59 -0800 (PST) From: Alexandre Courbot X-Google-Original-From: Alexandre Courbot To: Arnd Bergmann Subject: [PATCH RESEND] ARM: DMA: Fix kzalloc flags in __iommu_alloc_buffer() Date: Wed, 11 Feb 2015 18:01:41 +0900 Message-Id: <1423645301-709-1-git-send-email-acourbot@nvidia.com> X-Mailer: git-send-email 2.3.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150211_010622_920282_78F2D8BA X-CRM114-Status: GOOD ( 12.41 ) X-Spam-Score: -0.8 (/) Cc: gnurou@gmail.com, Russell King , Will Deacon , linux-kernel@vger.kernel.org, Alexandre Courbot , linux-arm-kernel@lists.infradead.org, Marek Szyprowski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There doesn't seem to be any valid reason to allocate the pages array with the same flags as the buffer itself. Doing so can eventually lead to the following safeguard in mm/slab.c to be hit: BUG_ON(flags & GFP_SLAB_BUG_MASK); This happens when buffers are allocated with __GFP_DMA32 or __GFP_HIGHMEM. Fix this by allocating the pages array with GFP_KERNEL to follow what is done elsewhere in this file. Using GFP_KERNEL in __iommu_alloc_buffer() is safe because atomic allocations are handled by __iommu_alloc_atomic(). Signed-off-by: Alexandre Courbot Cc: Arnd Bergmann Cc: Marek Szyprowski Cc: Russell King Acked-by: Marek Szyprowski --- arch/arm/mm/dma-mapping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 903dba0..170a116 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1106,7 +1106,7 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, int i = 0; if (array_size <= PAGE_SIZE) - pages = kzalloc(array_size, gfp); + pages = kzalloc(array_size, GFP_KERNEL); else pages = vzalloc(array_size); if (!pages)