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: 33367 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 487C1208CF for ; Thu, 10 Jul 2014 02:30:57 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id s7sf7605839qap.7 for ; Wed, 09 Jul 2014 19:30:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=DPvSv3Aajl0dmstm0ofiVeKudtMTHYxl6+hmV9l0/hw=; b=gn1InhQGZpIQK9V3UxT3o3kEheXMx/Zvl4DqIIKJkK6gTSCnuV34oW2rk/2ryf4QDy oWaribpVXcUVtYZkbuwEpzfVd1fYTeDxUE68gHavEHd0OPhTrlsqLu9dO39oG2qpXeFB 15hzew+1oDi7my692SGv6r69C3lDO//luOWaEyouUtIQx9ex73DpjmqsSOwWQbGJ0WiM TUs90wMIl532eKN7rc+MH1OEQMJmJqT58F9ESgNVsEi+Pmtyva4B/Y33xb7iO2EpdU64 goKh+kKmxtSHFzGM5B2BWAz7A8nDS9WpjwVPtCkZJwUjfPuZrulsEOHcfEYf+Gq6JtAo 4R9g== X-Gm-Message-State: ALoCoQm/OcY2FLZwF5t1kYB2N4DGC4C5NoE09En+Z+cFDjLexojO8f+44MpPXnhMtTz81n0oR+fF X-Received: by 10.224.103.135 with SMTP id k7mr21607344qao.6.1404959457139; Wed, 09 Jul 2014 19:30:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.51 with SMTP id s48ls254148qgs.64.gmail; Wed, 09 Jul 2014 19:30:57 -0700 (PDT) X-Received: by 10.220.190.197 with SMTP id dj5mr42212731vcb.19.1404959457021; Wed, 09 Jul 2014 19:30:57 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id ad18si22398326vec.43.2014.07.09.19.30.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Jul 2014 19:30:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id ij19so9459374vcb.9 for ; Wed, 09 Jul 2014 19:30:56 -0700 (PDT) X-Received: by 10.58.210.168 with SMTP id mv8mr43054001vec.12.1404959456897; Wed, 09 Jul 2014 19:30:56 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp94713vcb; Wed, 9 Jul 2014 19:30:56 -0700 (PDT) X-Received: by 10.68.125.135 with SMTP id mq7mr24634981pbb.103.1404959456094; Wed, 09 Jul 2014 19:30:56 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u2si8012847pdj.450.2014.07.09.19.30.55; Wed, 09 Jul 2014 19:30:55 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755752AbaGJCar (ORCPT + 28 others); Wed, 9 Jul 2014 22:30:47 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:52509 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754201AbaGJCap (ORCPT ); Wed, 9 Jul 2014 22:30:45 -0400 Received: by mail-pd0-f169.google.com with SMTP id ft15so3205223pdb.0 for ; Wed, 09 Jul 2014 19:30:45 -0700 (PDT) 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 Cc: Haojian Zhuang 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: haojian.zhuang@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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; }