]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - kernel/fork.c
ppp: fix race in ppp device destruction
[mirror_ubuntu-bionic-kernel.git] / kernel / fork.c
index 10646182440fa4c3a3a8da7d9fdb7b45f01aab26..e702cb9ffbd85ab7ff388c17654f729614d0b296 100644 (file)
@@ -946,6 +946,24 @@ void mmput(struct mm_struct *mm)
 }
 EXPORT_SYMBOL_GPL(mmput);
 
+#ifdef CONFIG_MMU
+static void mmput_async_fn(struct work_struct *work)
+{
+       struct mm_struct *mm = container_of(work, struct mm_struct,
+                                           async_put_work);
+
+       __mmput(mm);
+}
+
+void mmput_async(struct mm_struct *mm)
+{
+       if (atomic_dec_and_test(&mm->mm_users)) {
+               INIT_WORK(&mm->async_put_work, mmput_async_fn);
+               schedule_work(&mm->async_put_work);
+       }
+}
+#endif
+
 /**
  * set_mm_exe_file - change a reference to the mm's executable file
  *