[CRIU] [PATCH 3/3] cg: Add rollback in get_cg_set

Andrew Vagin avagin at virtuozzo.com
Sat Apr 2 00:17:18 PDT 2016


On Thu, Mar 31, 2016 at 05:39:45PM +0300, Cyrill Gorcunov wrote:
> From: Cyrill Gorcunov <gorcunov at virtuozzo.com>
> 
> In case of error inside collect_cgroups we need
> 
> - @ctls list has been spliced into @cs->ctls so we cant just free it,
>    but rather use put_ctls on @cs->ctls
> 
> - delete @cs->l from global @cg_sets list before free it
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
> ---
>  criu/cgroup.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/criu/cgroup.c b/criu/cgroup.c
> index 44caf3c42fcb..e6b371ddc536 100644
> --- a/criu/cgroup.c
> +++ b/criu/cgroup.c
> @@ -203,8 +203,11 @@ static struct cg_set *get_cg_set(struct list_head *ctls, unsigned int n_ctls, bo
>  		}
>  
>  		if (collect && collect_cgroups(&cs->ctls)) {
> -			put_ctls(ctls);
> +			list_del(&cs->l);
> +			n_sets--;

Can we call collect_cgroups() before filling cs?

> +			put_ctls(&cs->ctls);
>  			xfree(cs);
> +			INIT_LIST_HEAD(ctls);

I think it's better to use list_splice_init() instead of
list_splice()

>  			return NULL;
>  		}
>  	}
> -- 
> 2.5.5
> 


More information about the CRIU mailing list