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 06/13] ARM: mmp: 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 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@gmail.com>
---
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
\
 
 \ /
  Last update: 2022-02-17 19:51    [W:1.051 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site