Commit b1689742 authored by Lorenzo Pieralisi's avatar Lorenzo Pieralisi Committed by Greg Kroah-Hartman

ACPI/IORT: Fix off-by-one check in iort_dev_find_its_id()

[ Upstream commit 5a46d3f7 ]

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: 4bf2efd2 ("ACPI: Add new IORT functions to support MSI domain handling")
Link: https://lore.kernel.org/linux-arm-kernel/20190613065410.GB16334@mwanda/Reviewed-by: default avatarHanjun Guo <guohanjun@huawei.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Will Deacon <will@kernel.org>
Cc: Hanjun Guo <guohanjun@huawei.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 38c919ec
...@@ -616,8 +616,8 @@ static int iort_dev_find_its_id(struct device *dev, u32 req_id, ...@@ -616,8 +616,8 @@ static int iort_dev_find_its_id(struct device *dev, u32 req_id,
/* Move to ITS specific data */ /* Move to ITS specific data */
its = (struct acpi_iort_its_group *)node->node_data; its = (struct acpi_iort_its_group *)node->node_data;
if (idx > its->its_count) { if (idx >= its->its_count) {
dev_err(dev, "requested ITS ID index [%d] is greater than available [%d]\n", dev_err(dev, "requested ITS ID index [%d] overruns ITS entries [%d]\n",
idx, its->its_count); idx, its->its_count);
return -ENXIO; return -ENXIO;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment