diff --git a/fs/file.c b/fs/file.c index 58f4acb5c8624393c1c6b1a9e9a64372389e585f..3b99457518ef5fc4933ae7d53a7b136af386483c 100644 --- a/fs/file.c +++ b/fs/file.c @@ -374,8 +374,12 @@ struct files_struct *dup_fd(struct files_struct *oldf, unsigned int max_fds, int rcu_assign_pointer(newf->fdt, new_fdt); #ifdef CONFIG_CGROUP_FILES - if (!files_cgroup_alloc_fd(newf, files_cgroup_count_fds(newf))) + spin_lock(&newf->file_lock); + if (!files_cgroup_alloc_fd(newf, files_cgroup_count_fds(newf))) { + spin_unlock(&newf->file_lock); return newf; + } + spin_unlock(&newf->file_lock); /* could not get enough FD resources. Need to clean up. */ new_fds = new_fdt->fd;