Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760506AbcKCVkB (ORCPT ); Thu, 3 Nov 2016 17:40:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36176 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760283AbcKCVj5 (ORCPT ); Thu, 3 Nov 2016 17:39:57 -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, pranav.sawargaonkar@gmail.com, iommu@lists.linux-foundation.org, punit.agrawal@arm.com, diana.craciun@nxp.com Subject: [RFC 2/8] iommu/iova: fix __alloc_and_insert_iova_range Date: Thu, 3 Nov 2016 21:39:32 +0000 Message-Id: <1478209178-3009-3-git-send-email-eric.auger@redhat.com> In-Reply-To: <1478209178-3009-1-git-send-email-eric.auger@redhat.com> References: <1478209178-3009-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.27]); Thu, 03 Nov 2016 21:39:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 810 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 @@ static int __alloc_and_insert_iova_range(struct iova_domain *iovad, 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