cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cgroup: fix fail path in cgroup_load_subsys()
@ 2013-12-07  7:58 Vladimir Davydov
       [not found] ` <1386403085-24866-1-git-send-email-vdavydov-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Vladimir Davydov @ 2013-12-07  7:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: cgroups, devel, Tejun Heo, Li Zefan

We should not call cgroup_unload_subsys() if online_css() fails, because
online_css() does not assign css to cgroup on failure, while
offline_css() called from cgroup_unload_subsys() expects it is assigned.
So let's call everything we need to rollback inline without involving
cgroup_unload_subsys().

Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
---
 kernel/cgroup.c |   23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 8b729c2..3cd7247 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4861,10 +4861,8 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss)
 	 */
 	css = ss->css_alloc(cgroup_css(cgroup_dummy_top, ss));
 	if (IS_ERR(css)) {
-		/* failure case - need to deassign the cgroup_subsys[] slot. */
-		cgroup_subsys[ss->subsys_id] = NULL;
-		mutex_unlock(&cgroup_mutex);
-		return PTR_ERR(css);
+		ret = PTR_ERR(css);
+		goto out_err;
 	}
 
 	list_add(&ss->sibling, &cgroup_dummy_root.subsys_list);
@@ -4873,6 +4871,10 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss)
 	/* our new subsystem will be attached to the dummy hierarchy. */
 	init_css(css, ss, cgroup_dummy_top);
 
+	ret = online_css(css);
+	if (ret)
+		goto free_css;
+
 	/*
 	 * Now we need to entangle the css into the existing css_sets. unlike
 	 * in cgroup_init_subsys, there are now multiple css_sets, so each one
@@ -4896,18 +4898,17 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss)
 	}
 	write_unlock(&css_set_lock);
 
-	ret = online_css(css);
-	if (ret)
-		goto err_unload;
-
 	/* success! */
 	mutex_unlock(&cgroup_mutex);
 	return 0;
 
-err_unload:
+free_css:
+	list_del(&ss->sibling);
+	ss->css_free(css);
+out_err:
+	/* failure case - need to deassign the cgroup_subsys[] slot. */
+	cgroup_subsys[ss->subsys_id] = NULL;
 	mutex_unlock(&cgroup_mutex);
-	/* @ss can't be mounted here as try_module_get() would fail */
-	cgroup_unload_subsys(ss);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(cgroup_load_subsys);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-12-12 18:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-07  7:58 [PATCH] cgroup: fix fail path in cgroup_load_subsys() Vladimir Davydov
     [not found] ` <1386403085-24866-1-git-send-email-vdavydov-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2013-12-12  6:01   ` Li Zefan
2013-12-12 15:35   ` Tejun Heo
     [not found]     ` <20131212153536.GD32683-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-12-12 15:55       ` Tejun Heo
     [not found]         ` <20131212155523.GF32683-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-12-12 18:37           ` Vladimir Davydov
     [not found]             ` <52AA026C.3040605-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2013-12-12 18:45               ` Tejun Heo
     [not found]                 ` <20131212184506.GK32683-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-12-12 18:51                   ` Vladimir Davydov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).