Skip to content

Commit

Permalink
Fix data race in vtty_delete.
Browse files Browse the repository at this point in the history
vtty_list is a linked list protected by a mutex.
vtty->pprev is part of the linked list and was being accessed without aquiring the lock.
  • Loading branch information
flaviojs committed Mar 24, 2024
1 parent edd9951 commit bf37219
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions common/dev_vtty.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,13 +569,13 @@ void vtty_delete(vtty_t *vtty)
int i;

if (vtty != NULL) {
VTTY_LIST_LOCK();
if (vtty->pprev != NULL) {
VTTY_LIST_LOCK();
if (vtty->next)
vtty->next->pprev = vtty->pprev;
*(vtty->pprev) = vtty->next;
VTTY_LIST_UNLOCK();
}
VTTY_LIST_UNLOCK();

switch(vtty->type) {
case VTTY_TYPE_TCP:
Expand Down

0 comments on commit bf37219

Please sign in to comment.