/* The call to cgroup_lock() in the freezer.state write method prevents a write to that file racing against an attach, and hence the can_attach() result will remain valid until the attach completes.  */
static int freezer_can_attach(struct cgroup_subsys *ss, struct cgroup *new_cgroup, struct task_struct *task, bool threadgroup)
/* The call to cgroup_lock() in the freezer.state write method prevents a write to that file racing against an attach, and hence the can_attach() result will remain valid until the attach completes.  */
static int freezer_can_attach(struct cgroup_subsys *ss, struct cgroup *new_cgroup, struct task_struct *task, bool threadgroup)
{
	struct freezer *freezer;
	if (is_task_frozen_enough(task))
		return -EBUSY;
	freezer = cgroup_freezer(new_cgroup);
	if (freezer->state == CGROUP_FROZEN)
		return -EBUSY;
	if (threadgroup) {
		struct task_struct *c;
		rcu_read_lock();
		list_for_each_entry_rcu(c, &task->thread_group, thread_group) {
			if (is_task_frozen_enough(c)) {
				rcu_read_unlock();
				return -EBUSY;
			}
		}
		rcu_read_unlock();
	}
	return 0;
}