Commit 688494a4 authored by Mark Salter's avatar Mark Salter Committed by Will Deacon

drivers/perf: thunderx2_pmu: Fix memory resource error handling

In tx2_uncore_pmu_init_dev(), a call to acpi_dev_get_resources() is used
to create a list _CRS resources which is searched for the device base
address. There is an error check following this:

   if (!rentry->res)
           return NULL

In no case, will rentry->res be NULL, so the test is useless. Even
if the test worked, it comes before the resource list memory is
freed. None of this really matters as long as the ACPI table has
the memory resource. Let's clean it up so that it makes sense and
will give a meaningful error should firmware leave out the memory
resource.

Fixes: 69c32972 ("drivers/perf: Add Cavium ThunderX2 SoC UNCORE PMU driver")
Signed-off-by: default avatarMark Salter <msalter@redhat.com>
Link: https://lore.kernel.org/r/20200915204110.326138-2-msalter@redhat.comSigned-off-by: default avatarWill Deacon <will@kernel.org>
parent a76b8236
...@@ -805,14 +805,17 @@ static struct tx2_uncore_pmu *tx2_uncore_pmu_init_dev(struct device *dev, ...@@ -805,14 +805,17 @@ static struct tx2_uncore_pmu *tx2_uncore_pmu_init_dev(struct device *dev,
list_for_each_entry(rentry, &list, node) { list_for_each_entry(rentry, &list, node) {
if (resource_type(rentry->res) == IORESOURCE_MEM) { if (resource_type(rentry->res) == IORESOURCE_MEM) {
res = *rentry->res; res = *rentry->res;
rentry = NULL;
break; break;
} }
} }
acpi_dev_free_resource_list(&list);
if (!rentry->res) if (rentry) {
dev_err(dev, "PMU type %d: Fail to find resource\n", type);
return NULL; return NULL;
}
acpi_dev_free_resource_list(&list);
base = devm_ioremap_resource(dev, &res); base = devm_ioremap_resource(dev, &res);
if (IS_ERR(base)) { if (IS_ERR(base)) {
dev_err(dev, "PMU type %d: Fail to map resource\n", type); dev_err(dev, "PMU type %d: Fail to map resource\n", type);
......
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