lkml.org 
[lkml]   [2022]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 05/13] drivers/perf: remove the usage of the list iterator after the loop
Date
To introduce a speculative safe list iterator, the iterator variable will
be set to NULL when the terminating condition of the loop is hit.

The code before assumed rentry would only be NULL if the break is
hit, this assumption no longer holds. Once the speculative safe list
iterator is merged the condition could be replace with if (!entry)
instead.

Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
drivers/perf/xgene_pmu.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c
index 2b6d476bd213..523ff5c53103 100644
--- a/drivers/perf/xgene_pmu.c
+++ b/drivers/perf/xgene_pmu.c
@@ -1463,6 +1463,7 @@ xgene_pmu_dev_ctx *acpi_get_pmu_hw_inf(struct xgene_pmu *xgene_pmu,
struct resource_entry *rentry;
int enable_bit;
int rc;
+ bool found = false;

ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
@@ -1478,13 +1479,13 @@ xgene_pmu_dev_ctx *acpi_get_pmu_hw_inf(struct xgene_pmu *xgene_pmu,
list_for_each_entry(rentry, &resource_list, node) {
if (resource_type(rentry->res) == IORESOURCE_MEM) {
res = *rentry->res;
- rentry = NULL;
+ found = true;
break;
}
}
acpi_dev_free_resource_list(&resource_list);

- if (rentry) {
+ if (!found) {
dev_err(dev, "PMU type %d: No memory resource found\n", type);
return NULL;
}
--
2.25.1
\
 
 \ /
  Last update: 2022-02-17 19:51    [W:0.177 / U:0.688 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site