Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933703AbcJLNYe (ORCPT ); Wed, 12 Oct 2016 09:24:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43282 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933361AbcJLNWj (ORCPT ); Wed, 12 Oct 2016 09:22:39 -0400 From: Eric Auger To: eric.auger@redhat.com, eric.auger.pro@gmail.com, christoffer.dall@linaro.org, marc.zyngier@arm.com, robin.murphy@arm.com, alex.williamson@redhat.com, will.deacon@arm.com, joro@8bytes.org, tglx@linutronix.de, jason@lakedaemon.net, linux-arm-kernel@lists.infradead.org Cc: kvm@vger.kernel.org, drjones@redhat.com, linux-kernel@vger.kernel.org, Bharat.Bhushan@freescale.com, pranav.sawargaonkar@gmail.com, p.fedin@samsung.com, iommu@lists.linux-foundation.org, Jean-Philippe.Brucker@arm.com, yehuday@marvell.com, Manish.Jaggi@caviumnetworks.com Subject: [PATCH v14 01/16] iommu/iova: fix __alloc_and_insert_iova_range Date: Wed, 12 Oct 2016 13:22:09 +0000 Message-Id: <1476278544-3397-2-git-send-email-eric.auger@redhat.com> In-Reply-To: <1476278544-3397-1-git-send-email-eric.auger@redhat.com> References: <1476278544-3397-1-git-send-email-eric.auger@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 12 Oct 2016 13:22:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 753 Lines: 27 Fix the size check within start_pfn and limit_pfn. Signed-off-by: Eric Auger --- the issue was observed when playing with 1 page iova domain with higher iova reserved. --- drivers/iommu/iova.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index e23001b..ee29dbf 100644 --- a/drivers/iommu/iova.c +++ b/drivers/iommu/iova.c @@ -147,7 +147,7 @@ move_left: if (!curr) { if (size_aligned) pad_size = iova_get_pad_size(size, limit_pfn); - if ((iovad->start_pfn + size + pad_size) > limit_pfn) { + if ((iovad->start_pfn + size + pad_size - 1) > limit_pfn) { spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags); return -ENOMEM; } -- 1.9.1