Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1073029ybl; Wed, 14 Aug 2019 10:15:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeLTCzmol2MPiOOZ549O4pSy8n5K05n2wjjV5uRkXFnYVtKCZCU50dco15tBIm1MCab/fS X-Received: by 2002:a62:d0:: with SMTP id 199mr990000pfa.157.1565802930035; Wed, 14 Aug 2019 10:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802930; cv=none; d=google.com; s=arc-20160816; b=jELeF3dLSASEGUabBNKvMtksUdxoLZEgxQzRhebfzM62MUfvT6QUsmKH2KgeR8X5F/ Y2QPnqQvG20XxjU7uPr+M/q4Geuuarjm0aMiLuAbyZDpjbbewhVurDi5f29Z8LHFxAQQ FPDkjbxNRw5KbZs73Sk+nzSq9hgfSCE7qYWt64IFTnxaNyD0DsCfbGdHrX7RxyoVeY2q BxU62h7O+AwHR3T8N375FsB9flzbCUZETpinIbvNCxDUrH5m1Hoy+diS2U/RsugL0ASU zQcl8NHqgS6ycXluA4bdTKvK7mWWuWCIW2GF3vZ8Ew+rw7dvMuRgVG9A4TPIA/HIK4I1 XtKg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DdDFPEeS3+cYU/y/bkQKyzpDDAeOiVUHTSJ4neoexqM=; b=x7EWlEn+r5ZDg+MRhwkqoUZ0CsT9QwTbm/6ZGsxEWJ7iIxVtZPieScKpSRM9/aLmsr fGdOQvpx0rM7d7jcBvaDOb9qFi2rj0HW7bdfhWV0Um/nIAtSplFODEpG/HPuanFAH/40 xkwNEDgfNjWGosqeZtfwMtUzgjmUHsAMyMa2Q8v2iJjoPD5CMNUnmu+7xvOv4oNyUN5d ZpA98/cwXJniUN+MnViIH73NTxiqxbADnO2dC9olApqP6EnJusmyPx3UZKoZL0m8yO+i PVPJ9uu3P6adInQovRdCz4UvXLgELO1y94g8prxnpYBIgxf6RAdOybUZ8sgylVNRAjL9 U9Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P9dtLkmX; 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 61si232993plb.270.2019.08.14.10.15.14; Wed, 14 Aug 2019 10:15:30 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=P9dtLkmX; 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 S1731100AbfHNROk (ORCPT + 99 others); Wed, 14 Aug 2019 13:14:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:39110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731106AbfHNROg (ORCPT ); Wed, 14 Aug 2019 13:14:36 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 063CB20665; Wed, 14 Aug 2019 17:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802876; bh=P+xKZoykRFBIK1haPKkOyTqNdvkHle2512pqLR/TUUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P9dtLkmX5bI1hrnuIinbendSJsM9uU4XY7/8+2AuNb0sdb3KLMW5zsA1DVyzyCX2x KqdTiFTLYmNoPJerpHMN2mnN5W9z12+i/KfwjfBg6A1R/9JhvzZWv4m4wPxT5fZZaO rwfPwMOLGLIa8cMdEHu6NUCzXwR1sEfD2ji7PLPA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hanjun Guo , Dan Carpenter , Lorenzo Pieralisi , Will Deacon , Sudeep Holla , Catalin Marinas , Robin Murphy , Sasha Levin Subject: [PATCH 4.14 43/69] ACPI/IORT: Fix off-by-one check in iort_dev_find_its_id() Date: Wed, 14 Aug 2019 19:01:41 +0200 Message-Id: <20190814165748.359949427@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165744.822314328@linuxfoundation.org> References: <20190814165744.822314328@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 5a46d3f71d5e5a9f82eabc682f996f1281705ac7 ] Static analysis identified that index comparison against ITS entries in iort_dev_find_its_id() is off by one. Update the comparison condition and clarify the resulting error message. Fixes: 4bf2efd26d76 ("ACPI: Add new IORT functions to support MSI domain handling") Link: https://lore.kernel.org/linux-arm-kernel/20190613065410.GB16334@mwanda/ Reviewed-by: Hanjun Guo Reported-by: Dan Carpenter Signed-off-by: Lorenzo Pieralisi Cc: Dan Carpenter Cc: Will Deacon Cc: Hanjun Guo Cc: Sudeep Holla Cc: Catalin Marinas Cc: Robin Murphy Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- drivers/acpi/arm64/iort.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index ca414910710ea..b0a7afd4e7d35 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -506,8 +506,8 @@ static int iort_dev_find_its_id(struct device *dev, u32 req_id, /* Move to ITS specific data */ its = (struct acpi_iort_its_group *)node->node_data; - if (idx > its->its_count) { - dev_err(dev, "requested ITS ID index [%d] is greater than available [%d]\n", + if (idx >= its->its_count) { + dev_err(dev, "requested ITS ID index [%d] overruns ITS entries [%d]\n", idx, its->its_count); return -ENXIO; } -- 2.20.1