Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2111541ybl; Thu, 9 Jan 2020 07:06:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzTMtrvv55wm7Gw6CgJkiQZqe1swAzUhTla34Z/YvXT1x0ZPWoLYkvTuiOwcQ2LqIMw/4vz X-Received: by 2002:aca:1111:: with SMTP id 17mr3274220oir.37.1578582396803; Thu, 09 Jan 2020 07:06:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578582396; cv=none; d=google.com; s=arc-20160816; b=nDbsKsnBIoSw8zz97tbvjim3pR/ewlp9/eF5Rt+4J2EW3Ys1oieNzYeBjOXQn2nk+Z dtj/09Jram1ebRIW0m+zHHqaoHLzP0gFsVb0esWmtA9wc8wroFQNOkqywrfSfV5mXnw2 5TQaV/f87wvmH75UDT6T0nl7ztKMD5bGXjUEU0X1D5th8cerpl+qME62ig2N68AlgkOV C1dUjZ4S/gyYYAeYBTDYPhPfK+SC9xTQr5l6fcdtZ/Hc5WRGGl9mWrH+ZQrIku1b9b9w gY9/DqjzDFh2fjtahPG5DVIpsZq9m3UK1Hz+3PshxtDEDCRnYIt46QfWYPb9srv7Ryv5 KqXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=66vNxp2S0VTQcawv5AGWVZrPX7J3LRU4Lewg5xzwrI0=; b=gYzJWEiBTMDj2yJBRqPmzjAKWRyTGeM3G+QsgZuj3sTWQMkeqYNNtkqS+u/nxbNDBk ZPeczRo5vaVHj+/qwRyScE1fr9i3Pw5/e4P8vlZjd1vQfOkH6rcXnlt0+RX8GMtQRhqY Sx46IbdLuqA7o6jmIsC0kEFdiyJZJ9A4F42m76/34ohy9OxO9sEE80udYI9yWVIdF+7i +UqpAJo3TRybuqEYqEzNiLcvosNrilUy7/ZlbFflMs0m8tDQhaD8yTRa8IePAY9gyA5l cUvS0oJC+xsbPtV61tRpSotuzz3F53usA4KVLKaqM2b5g/pIL+vBHNHWWWsVc4k1Ux1u W1CQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b18si3682348oib.170.2020.01.09.07.06.22; Thu, 09 Jan 2020 07:06:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730987AbgAINXR (ORCPT + 99 others); Thu, 9 Jan 2020 08:23:17 -0500 Received: from foss.arm.com ([217.140.110.172]:58962 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727861AbgAINXR (ORCPT ); Thu, 9 Jan 2020 08:23:17 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C00EE31B; Thu, 9 Jan 2020 05:23:16 -0800 (PST) Received: from [10.1.196.37] (e121345-lin.cambridge.arm.com [10.1.196.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DAA833F534; Thu, 9 Jan 2020 05:23:15 -0800 (PST) Subject: Re: [PATCH] iommu/arm-smmu-v3: fix resource_size check To: Masahiro Yamada , Will Deacon , linux-arm-kernel@lists.infradead.org, Joerg Roedel , iommu@lists.linux-foundation.org Cc: linux-kernel@vger.kernel.org References: <20191226095056.30256-1-yamada.masahiro@socionext.com> From: Robin Murphy Message-ID: <2cd8ed11-56df-b46b-aa21-5ecc0e2e3082@arm.com> Date: Thu, 9 Jan 2020 13:23:14 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191226095056.30256-1-yamada.masahiro@socionext.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26/12/2019 9:50 am, Masahiro Yamada wrote: > This is an off-by-one mistake. > > resource_size() returns res->end - res->start + 1. Heh, despite the optimism of "Avoid one-off errors by introducing a resource_size() function", life finds a way... Reviewed-by: Robin Murphy > Signed-off-by: Masahiro Yamada > --- > > drivers/iommu/arm-smmu-v3.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c > index d9e0d9c19b4f..b463599559d2 100644 > --- a/drivers/iommu/arm-smmu-v3.c > +++ b/drivers/iommu/arm-smmu-v3.c > @@ -3599,7 +3599,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev) > > /* Base address */ > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > - if (resource_size(res) + 1 < arm_smmu_resource_size(smmu)) { > + if (resource_size(res) < arm_smmu_resource_size(smmu)) { > dev_err(dev, "MMIO region too small (%pr)\n", res); > return -EINVAL; > } >