summaryrefslogtreecommitdiffstats
path: root/lib/zlog.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2022-03-05 19:39:53 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2022-03-07 17:23:12 +0100
commitd03440cab78605dcc21427127afdf78860d9916b (patch)
treeaf7ac444e2b20e7fc7b692663994e038fb6fb69b /lib/zlog.c
parentMerge pull request #10745 from mjstapp/fix_doc_star_again (diff)
downloadfrr-d03440cab78605dcc21427127afdf78860d9916b.tar.xz
frr-d03440cab78605dcc21427127afdf78860d9916b.zip
lib: fix log target removal when singlethreaded
While running singlethreaded, the RCU code is "dormant" and rcu_free is an immediate operation. This results in the log target loop accessing free'd memory if a log target removes itself while a message is printed (which is likely to happen on e.g. error conditions.) Just use frr_each_safe to avoid this issue. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/zlog.c')
-rw-r--r--lib/zlog.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/zlog.c b/lib/zlog.c
index 85606d262..e0bb34a25 100644
--- a/lib/zlog.c
+++ b/lib/zlog.c
@@ -401,7 +401,7 @@ void zlog_tls_buffer_flush(void)
return;
rcu_read_lock();
- frr_each (zlog_targets, &zlog_targets, zt) {
+ frr_each_safe (zlog_targets, &zlog_targets, zt) {
if (!zt->logfn)
continue;
@@ -431,7 +431,7 @@ static void vzlog_notls(const struct xref_logmsg *xref, int prio,
msg->stackbufsz = sizeof(stackbuf);
rcu_read_lock();
- frr_each (zlog_targets, &zlog_targets, zt) {
+ frr_each_safe (zlog_targets, &zlog_targets, zt) {
if (prio > zt->prio_min)
continue;
if (!zt->logfn)