All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Vladimir Davydov <vdavydov-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org,
	Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH] cgroup: fix fail path in cgroup_load_subsys()
Date: Thu, 12 Dec 2013 14:01:12 +0800	[thread overview]
Message-ID: <52A95128.9020309@huawei.com> (raw)
In-Reply-To: <1386403085-24866-1-git-send-email-vdavydov-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>

> @@ -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;
> -

Moving online_css() upwards should be fine.

Acked-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

>  	/* 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);
> 

WARNING: multiple messages have this Message-ID (diff)
From: Li Zefan <lizefan@huawei.com>
To: Vladimir Davydov <vdavydov@parallels.com>
Cc: <linux-kernel@vger.kernel.org>, <cgroups@vger.kernel.org>,
	<devel@openvz.org>, Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH] cgroup: fix fail path in cgroup_load_subsys()
Date: Thu, 12 Dec 2013 14:01:12 +0800	[thread overview]
Message-ID: <52A95128.9020309@huawei.com> (raw)
In-Reply-To: <1386403085-24866-1-git-send-email-vdavydov@parallels.com>

> @@ -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;
> -

Moving online_css() upwards should be fine.

Acked-by: Li Zefan <lizefan@huawei.com>

>  	/* 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);
> 


  parent reply	other threads:[~2013-12-12  6:01 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52A95128.9020309@huawei.com \
    --to=lizefan-hv44wf8li93qt0dzr+alfa@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=devel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=vdavydov-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.