Skip to content

Commit 29f51ff

Browse files
committed
fix: hold link_lock when freeing duplicate local LinkTable
Prevent race conditions where concurrent `releasedir` calls could free and set `next_table` to NULL in the window between unlocking and relocking. Since `LinkTable_free` only operates on the local, unattached duplicate table, it does not require dropping `link_lock`.
1 parent 796fbb9 commit 29f51ff

1 file changed

Lines changed: 0 additions & 4 deletions

File tree

src/link.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -972,9 +972,7 @@ LinkTable *path_to_LinkTable(const char *path)
972972
new_table->orphaned = 0;
973973
next_table = new_table;
974974
} else {
975-
PTHREAD_MUTEX_UNLOCK(&link_lock);
976975
LinkTable_free(new_table);
977-
PTHREAD_MUTEX_LOCK(&link_lock);
978976
next_table = link->next_table;
979977
next_table->refcount++;
980978
next_table->orphaned = 0;
@@ -1097,9 +1095,7 @@ static Link *path_to_Link_recursive(char *path, LinkTable *linktbl)
10971095
linktbl->refcount++;
10981096
next_table = new_table;
10991097
} else {
1100-
PTHREAD_MUTEX_UNLOCK(&link_lock);
11011098
LinkTable_free(new_table);
1102-
PTHREAD_MUTEX_LOCK(&link_lock);
11031099
next_table = linktbl->links[i]->next_table;
11041100
}
11051101
linktbl->refcount--;

0 commit comments

Comments
 (0)