Skip to content

Commit

Permalink
zebra: fnc->obuf could be accessed without a lock
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
donaldsharp committed Mar 4, 2024
1 parent c256a9a commit e7a1fbb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion zebra/dplane_fpm_nl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e7a1fbb

Please sign in to comment.