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 08/13] net: dsa: future proof usage of list iterator after the loop
Date
With the speculative safe version of the list iterator p will be NULL if
the terminating condition was hit and needs to be reset to p derived
from the head, before using p->list.

Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
drivers/net/dsa/sja1105/sja1105_vl.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/net/dsa/sja1105/sja1105_vl.c b/drivers/net/dsa/sja1105/sja1105_vl.c
index f5dca6a9b0f9..a4f2b95b09c4 100644
--- a/drivers/net/dsa/sja1105/sja1105_vl.c
+++ b/drivers/net/dsa/sja1105/sja1105_vl.c
@@ -40,6 +40,8 @@ static int sja1105_insert_gate_entry(struct sja1105_gating_config *gating_cfg,
if (e->interval < p->interval)
break;
}
+ if (!p)
+ p = list_entry(p, &gating_cfg->entries, list);
list_add(&e->list, p->list.prev);
}

--
2.25.1
\
 
 \ /
  Last update: 2022-02-17 19:51    [W:0.290 / U:0.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site