From e7a1fbbcf64659ae2057a2e1e20a6c1f842522ab Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 4 Mar 2024 18:07:42 -0500 Subject: [PATCH] zebra: fnc->obuf could be accessed without a lock Found by coverity. Let's just lock the writeable amount to see if it is possible. It's ok because we want to know if we have room *now*. If another pthread runs it will only remove data from fnc->obuf and make more room. So this is ok. Signed-off-by: Donald Sharp --- zebra/dplane_fpm_nl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zebra/dplane_fpm_nl.c b/zebra/dplane_fpm_nl.c index 7ae1b2a090..ef4824028f 100644 --- a/zebra/dplane_fpm_nl.c +++ b/zebra/dplane_fpm_nl.c @@ -1394,8 +1394,14 @@ static void fpm_process_queue(struct event *t) uint64_t processed_contexts = 0; while (true) { + size_t writeable_amount; + + frr_with_mutex (&fnc->obuf_mutex) { + writeable_amount = STREAM_WRITEABLE(fnc->obuf); + } + /* No space available yet. */ - if (STREAM_WRITEABLE(fnc->obuf) < NL_PKT_BUF_SIZE) { + if (writeable_amount < NL_PKT_BUF_SIZE) { no_bufs = true; break; } -- 2.39.5