aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 8fe8c0cb137b..dee025f2f286 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2042,10 +2042,13 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
2042 struct cgroup *cgrp; 2042 struct cgroup *cgrp;
2043 struct cgroup_iter it; 2043 struct cgroup_iter it;
2044 struct task_struct *tsk; 2044 struct task_struct *tsk;
2045
2045 /* 2046 /*
2046 * Validate dentry by checking the superblock operations 2047 * Validate dentry by checking the superblock operations,
2048 * and make sure it's a directory.
2047 */ 2049 */
2048 if (dentry->d_sb->s_op != &cgroup_ops) 2050 if (dentry->d_sb->s_op != &cgroup_ops ||
2051 !S_ISDIR(dentry->d_inode->i_mode))
2049 goto err; 2052 goto err;
2050 2053
2051 ret = 0; 2054 ret = 0;
@@ -2475,10 +2478,7 @@ static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry)
2475 mutex_unlock(&cgroup_mutex); 2478 mutex_unlock(&cgroup_mutex);
2476 return -EBUSY; 2479 return -EBUSY;
2477 } 2480 }
2478 2481 mutex_unlock(&cgroup_mutex);
2479 parent = cgrp->parent;
2480 root = cgrp->root;
2481 sb = root->sb;
2482 2482
2483 /* 2483 /*
2484 * Call pre_destroy handlers of subsys. Notify subsystems 2484 * Call pre_destroy handlers of subsys. Notify subsystems
@@ -2486,7 +2486,14 @@ static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry)
2486 */ 2486 */
2487 cgroup_call_pre_destroy(cgrp); 2487 cgroup_call_pre_destroy(cgrp);
2488 2488
2489 if (cgroup_has_css_refs(cgrp)) { 2489 mutex_lock(&cgroup_mutex);
2490 parent = cgrp->parent;
2491 root = cgrp->root;
2492 sb = root->sb;
2493
2494 if (atomic_read(&cgrp->count)
2495 || !list_empty(&cgrp->children)
2496 || cgroup_has_css_refs(cgrp)) {
2490 mutex_unlock(&cgroup_mutex); 2497 mutex_unlock(&cgroup_mutex);
2491 return -EBUSY; 2498 return -EBUSY;
2492 } 2499 }