Skip to content

Commit e7a1fbb

Browse files
committed
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 <[email protected]>
1 parent c256a9a commit e7a1fbb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

zebra/dplane_fpm_nl.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,8 +1394,14 @@ static void fpm_process_queue(struct event *t)
13941394
uint64_t processed_contexts = 0;
13951395

13961396
while (true) {
1397+
size_t writeable_amount;
1398+
1399+
frr_with_mutex (&fnc->obuf_mutex) {
1400+
writeable_amount = STREAM_WRITEABLE(fnc->obuf);
1401+
}
1402+
13971403
/* No space available yet. */
1398-
if (STREAM_WRITEABLE(fnc->obuf) < NL_PKT_BUF_SIZE) {
1404+
if (writeable_amount < NL_PKT_BUF_SIZE) {
13991405
no_bufs = true;
14001406
break;
14011407
}

0 commit comments

Comments
 (0)