Эх сурвалжийг харах

Merge branch 'for-3.13-fixes' into for-3.14

Pulling in as patches depending on 266ccd505e8a ("cgroup: fix
cgroup_create() error handling path") are scheduled.

Signed-off-by: Tejun Heo <tj@kernel.org>
Tejun Heo 11 жил өмнө
parent
commit
e58e1ca438
1 өөрчлөгдсөн 21 нэмэгдсэн , 10 устгасан
  1. 21 10
      kernel/cgroup.c

+ 21 - 10
kernel/cgroup.c

@@ -4162,14 +4162,6 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
 	list_add_tail_rcu(&cgrp->sibling, &cgrp->parent->children);
 	list_add_tail_rcu(&cgrp->sibling, &cgrp->parent->children);
 	root->number_of_cgroups++;
 	root->number_of_cgroups++;
 
 
-	/* each css holds a ref to the cgroup's dentry and the parent css */
-	for_each_root_subsys(root, ss) {
-		struct cgroup_subsys_state *css = css_ar[ss->subsys_id];
-
-		dget(dentry);
-		css_get(css->parent);
-	}
-
 	/* hold a ref to the parent's dentry */
 	/* hold a ref to the parent's dentry */
 	dget(parent->dentry);
 	dget(parent->dentry);
 
 
@@ -4181,6 +4173,13 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
 		if (err)
 		if (err)
 			goto err_destroy;
 			goto err_destroy;
 
 
+		/* each css holds a ref to the cgroup's dentry and parent css */
+		dget(dentry);
+		css_get(css->parent);
+
+		/* mark it consumed for error path */
+		css_ar[ss->subsys_id] = NULL;
+
 		if (ss->broken_hierarchy && !ss->warned_broken_hierarchy &&
 		if (ss->broken_hierarchy && !ss->warned_broken_hierarchy &&
 		    parent->parent) {
 		    parent->parent) {
 			pr_warning("cgroup: %s (%d) created nested cgroup for controller \"%s\" which has incomplete hierarchy support. Nested cgroups may change behavior in the future.\n",
 			pr_warning("cgroup: %s (%d) created nested cgroup for controller \"%s\" which has incomplete hierarchy support. Nested cgroups may change behavior in the future.\n",
@@ -4227,6 +4226,14 @@ err_free_cgrp:
 	return err;
 	return err;
 
 
 err_destroy:
 err_destroy:
+	for_each_root_subsys(root, ss) {
+		struct cgroup_subsys_state *css = css_ar[ss->subsys_id];
+
+		if (css) {
+			percpu_ref_cancel_init(&css->refcnt);
+			ss->css_free(css);
+		}
+	}
 	cgroup_destroy_locked(cgrp);
 	cgroup_destroy_locked(cgrp);
 	mutex_unlock(&cgroup_mutex);
 	mutex_unlock(&cgroup_mutex);
 	mutex_unlock(&dentry->d_inode->i_mutex);
 	mutex_unlock(&dentry->d_inode->i_mutex);
@@ -4387,8 +4394,12 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
 	 * will be invoked to perform the rest of destruction once the
 	 * will be invoked to perform the rest of destruction once the
 	 * percpu refs of all css's are confirmed to be killed.
 	 * percpu refs of all css's are confirmed to be killed.
 	 */
 	 */
-	for_each_root_subsys(cgrp->root, ss)
-		kill_css(cgroup_css(cgrp, ss));
+	for_each_root_subsys(cgrp->root, ss) {
+		struct cgroup_subsys_state *css = cgroup_css(cgrp, ss);
+
+		if (css)
+			kill_css(css);
+	}
 
 
 	/*
 	/*
 	 * Mark @cgrp dead.  This prevents further task migration and child
 	 * Mark @cgrp dead.  This prevents further task migration and child