mapfree: fix potential race between init and exit

This commit is contained in:
Thomas Schoebel-Theuer 2021-11-03 14:04:22 +01:00
parent 77b7ea1589
commit a8039c4a70
1 changed files with 6 additions and 2 deletions

View File

@ -519,15 +519,19 @@ int __init init_mars_mapfree(void)
MARS_DBG("init_mapfree()\n");
mapfree_sleep_jiffies = MAPFREE_SLEEP_JIFFIES;
for (i = 0; i < MAPFREE_HASH; i++) {
struct task_struct *thread;
init_rwsem(&mf_table[i].hash_mutex);
INIT_LIST_HEAD(&mf_table[i].hash_anchor);
mf_table[i].hash_thread = NULL;
}
for (i = 0; i < MAPFREE_HASH; i++) {
struct task_struct *thread;
thread = brick_thread_create(mapfree_thread,
&mf_table[i],
"mars_mf%d", i);
if (unlikely(!thread)) {
MARS_ERR("could not create mapfree thread %d\n", i);
exit_mars_mapfree();
return -ENOMEM;
}
mf_table[i].hash_thread = thread;