[RFC PATCH 06/13] ARM: mmp: remove the usage of the list iterator after the loop

From: Jakob Koschel
Date: Thu Feb 17 2022 - 13:50:43 EST


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 info would be derived from the head if
the break did not hit, this assumption no longer holds.
Once the speculative safe list iterator is merged the condition could
be replace with if (!info) instead.

Signed-off-by: Jakob Koschel <jakobkoschel@xxxxxxxxx>
---
arch/arm/mach-mmp/sram.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mmp/sram.c b/arch/arm/mach-mmp/sram.c
index 6794e2db1ad5..b163d2da53e7 100644
--- a/arch/arm/mach-mmp/sram.c
+++ b/arch/arm/mach-mmp/sram.c
@@ -39,6 +39,7 @@ static LIST_HEAD(sram_bank_list);
struct gen_pool *sram_get_gpool(char *pool_name)
{
struct sram_bank_info *info = NULL;
+ bool found = false;

if (!pool_name)
return NULL;
@@ -46,12 +47,14 @@ struct gen_pool *sram_get_gpool(char *pool_name)
mutex_lock(&sram_lock);

list_for_each_entry(info, &sram_bank_list, node)
- if (!strcmp(pool_name, info->pool_name))
+ if (!strcmp(pool_name, info->pool_name)) {
+ found = true;
break;
+ }

mutex_unlock(&sram_lock);

- if (&info->node == &sram_bank_list)
+ if (!found)
return NULL;

return info->gpool;
--
2.25.1