diff options
-rw-r--r-- | kernel/cgroup.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 00d5136d38c2..61e92c5867ea 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -1214,7 +1214,7 @@ int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk) | |||
1214 | int retval = 0; | 1214 | int retval = 0; |
1215 | struct cgroup_subsys *ss; | 1215 | struct cgroup_subsys *ss; |
1216 | struct cgroup *oldcgrp; | 1216 | struct cgroup *oldcgrp; |
1217 | struct css_set *cg = tsk->cgroups; | 1217 | struct css_set *cg; |
1218 | struct css_set *newcg; | 1218 | struct css_set *newcg; |
1219 | struct cgroupfs_root *root = cgrp->root; | 1219 | struct cgroupfs_root *root = cgrp->root; |
1220 | int subsys_id; | 1220 | int subsys_id; |
@@ -1234,11 +1234,16 @@ int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk) | |||
1234 | } | 1234 | } |
1235 | } | 1235 | } |
1236 | 1236 | ||
1237 | task_lock(tsk); | ||
1238 | cg = tsk->cgroups; | ||
1239 | get_css_set(cg); | ||
1240 | task_unlock(tsk); | ||
1237 | /* | 1241 | /* |
1238 | * Locate or allocate a new css_set for this task, | 1242 | * Locate or allocate a new css_set for this task, |
1239 | * based on its final set of cgroups | 1243 | * based on its final set of cgroups |
1240 | */ | 1244 | */ |
1241 | newcg = find_css_set(cg, cgrp); | 1245 | newcg = find_css_set(cg, cgrp); |
1246 | put_css_set(cg); | ||
1242 | if (!newcg) | 1247 | if (!newcg) |
1243 | return -ENOMEM; | 1248 | return -ENOMEM; |
1244 | 1249 | ||