From patchwork Thu Jul 10 02:28:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 4520491 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0700B9F26C for ; Thu, 10 Jul 2014 02:33:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 42FEB20304 for ; Thu, 10 Jul 2014 02:33:26 +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 630AE202FF for ; Thu, 10 Jul 2014 02:33:25 +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 1X548b-0001qq-01; Thu, 10 Jul 2014 02:31:09 +0000 Received: from mail-pd0-f174.google.com ([209.85.192.174]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X548Y-0001lY-Ag for linux-arm-kernel@lists.infradead.org; Thu, 10 Jul 2014 02:31:06 +0000 Received: by mail-pd0-f174.google.com with SMTP id y10so9875495pdj.5 for ; Wed, 09 Jul 2014 19:30:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YmEmO7ti9UNPvP++666BQSiCNHpzbgOAb7Aq5rj89Gg=; b=IstRX6mVIoymiEzsBLdZEXDWrw/w+L8rH1s1J6STj3YGVAtadQRpoCcFLRykn4IMyk hb1C96lrjUtZMiz3jjjmM+wbKZKc0VWLQR/xZKxZ20GjkK+nsi8ddgVS8vGsuT48HusI Oj6cxLnKyWp29NGqmXSJAX5LB+vGaHvCYY1271zHWs/nLeb3tXFvKlwRFPaYv/qn8Pj5 BzW8IflpH0LVxwelBc2ac0Ohoisg8eJqyHk2jJaRE1D3vP3fXjvhrG8S+MwQdApaxb37 69lK1V+15nbQlUX7Xu3E1Iw1sRYIvCA8nIaaQEf9mdwE1hFwJgjq8SsHPJSEftGATC0v EGsA== X-Gm-Message-State: ALoCoQlZd7i+tN+FU1WQlsS+O4PZzqtIw7OYfKTAbuFDjH6s81i747y5GOXT8ZKfff3ieCATPo77 X-Received: by 10.70.98.167 with SMTP id ej7mr14476899pdb.70.1404959445541; Wed, 09 Jul 2014 19:30:45 -0700 (PDT) Received: from localhost.localdomain ([174.139.74.226]) by mx.google.com with ESMTPSA id z2sm6069700pdp.91.2014.07.09.19.30.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Jul 2014 19:30:44 -0700 (PDT) From: Haojian Zhuang To: linux@arm.linux.org.uk, m.szyprowski@samsung.com, will.deacon@arm.com, andreas.herrmann@calxeda.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] ARM: mm: fix the boundary checking on bitmaps Date: Thu, 10 Jul 2014 10:28:33 +0800 Message-Id: <1404959313-15198-1-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140709_193106_393967_8494A553 X-CRM114-Status: GOOD ( 15.17 ) X-Spam-Score: -0.7 (/) Cc: Haojian Zhuang 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=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 The issue of boundary checking on bitmaps is introduced by this commit in below. commit 4d852ef8c2544ce21ae41414099a7504c61164a0 Author: Andreas Herrmann Date: Tue Feb 25 13:09:53 2014 +0100 arm: dma-mapping: Add support to extend DMA IOMMU mappings Multiple bitmaps were introduced as extension. If it needs to extend a bitmap, it still check whether the allocation exceeding the total size, not current bitmap size. So change the condition from mapping->bits to PAGE_SIZE. Signed-off-by: Haojian Zhuang --- arch/arm/mm/dma-mapping.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 4c88935..d7da5c3 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1089,9 +1089,9 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping, spin_lock_irqsave(&mapping->lock, flags); for (i = 0; i < mapping->nr_bitmaps; i++) { start = bitmap_find_next_zero_area(mapping->bitmaps[i], - mapping->bits, 0, count, align); + PAGE_SIZE, 0, count, align); - if (start > mapping->bits) + if (start > PAGE_SIZE) continue; bitmap_set(mapping->bitmaps[i], start, count); @@ -1110,9 +1110,9 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping, } start = bitmap_find_next_zero_area(mapping->bitmaps[i], - mapping->bits, 0, count, align); + PAGE_SIZE, 0, count, align); - if (start > mapping->bits) { + if (start > PAGE_SIZE) { spin_unlock_irqrestore(&mapping->lock, flags); return DMA_ERROR_CODE; }