Skip to content

Commit e703b7e

Browse files
committed
futex: Move futex cleanup to __mmdrop()
Futex hash allocations are done in mm_init() and the cleanup happens in __mmput(). That works most of the time, but there are mm instances which are instantiated via mm_alloc() and freed via mmdrop(), which causes the futex hash to be leaked. Move the cleanup to __mmdrop(). Fixes: 56180dd ("futex: Use RCU-based per-CPU reference counting instead of rcuref_t") Reported-by: André Draszik <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: André Draszik <[email protected]> Link: https://lore.kernel.org/all/87ldo5ihu0.ffs@tglx Closes: https://lore.kernel.org/all/[email protected]
1 parent 98e8f2c commit e703b7e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/fork.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ void __mmdrop(struct mm_struct *mm)
686686
mm_pasid_drop(mm);
687687
mm_destroy_cid(mm);
688688
percpu_counter_destroy_many(mm->rss_stat, NR_MM_COUNTERS);
689+
futex_hash_free(mm);
689690

690691
free_mm(mm);
691692
}
@@ -1133,7 +1134,6 @@ static inline void __mmput(struct mm_struct *mm)
11331134
if (mm->binfmt)
11341135
module_put(mm->binfmt->module);
11351136
lru_gen_del_mm(mm);
1136-
futex_hash_free(mm);
11371137
mmdrop(mm);
11381138
}
11391139

0 commit comments

Comments
 (0)