Linux Container Development
 help / color / mirror / Atom feed
From: Cedric Le Goater <clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
To: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
Cc: containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>,
	Dave Hansen <dave-gkUM19QKKo4@public.gmane.org>
Subject: Re: External checkpoint patch
Date: Thu, 23 Oct 2008 09:51:13 +0200	[thread overview]
Message-ID: <49002CF1.3070505@fr.ibm.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0810211857140.22085-CXF6herHY6ykSYb+qCZC/1i27PF6R63G9nwVQlTi/Pw@public.gmane.org>

minor issue,


> -struct cr_ctx *cr_ctx_alloc(pid_t pid, int fd, unsigned long flags)
> +static struct cr_ctx *cr_ctx_alloc(pid_t pid, int fd, unsigned long flags)
>  {
>  	struct cr_ctx *ctx;
> +	int err;
> 
>  	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
>  	if (!ctx)
>  		return ERR_PTR(-ENOMEM);

with the err goto, you're calling cr_ctx_free() in a few places where
ctx is partially initialized. you should at least do :

	INIT_LIST_HEAD(&ctx->pgarr_list);

right after the kzalloc() and probably check the value of ctx->hbuf. 
There might be other issues.

> +	ctx->flags = flags;
> +	ctx->pid = pid;
> +
> +	err = -EBADF;
>  	ctx->file = fget(fd);
> -	if (!ctx->file) {
> -		cr_ctx_free(ctx);
> -		return ERR_PTR(-EBADF);
> -	}
> +	if (!ctx->file)
> +		goto err;
>
> 
> +	err = -ENOMEM;
>  	ctx->hbuf = kmalloc(CR_HBUF_TOTAL, GFP_KERNEL);
> -	if (!ctx->hbuf) {
> -		cr_ctx_free(ctx);
> -		return ERR_PTR(-ENOMEM);
> -	}
> +	if (!ctx->hbuf)
> +		goto err;
> 
> -	if (cr_objhash_alloc(ctx) < 0) {
> -		cr_ctx_free(ctx);
> -		return ERR_PTR(-ENOMEM);
> -	}
> +	if (cr_objhash_alloc(ctx) < 0)
> +		goto err;
> 
>  	/*
>  	 * assume checkpointer is in container's root vfs
> @@ -206,12 +206,13 @@ struct cr_ctx *cr_ctx_alloc(pid_t pid, int fd, unsigned long flags)
> 
>  	INIT_LIST_HEAD(&ctx->pgarr_list);
> 
> -	ctx->pid = pid;
> -	ctx->flags = flags;
> -
>  	ctx->crid = atomic_inc_return(&cr_ctx_count);
> 
>  	return ctx;
> +
> + err:
> +	cr_ctx_free(ctx);
> +	return ERR_PTR(err);
>  }
> 
>  /**

here's a patch for it.

C.

Signed-off-by: Cedric Le Goater <clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
---
 checkpoint/sys.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: 2.6.27-lxc/checkpoint/sys.c
===================================================================
--- 2.6.27-lxc.orig/checkpoint/sys.c
+++ 2.6.27-lxc/checkpoint/sys.c
@@ -217,7 +217,8 @@ static void cr_ctx_free(struct cr_ctx *c
 	if (ctx->file)
 		fput(ctx->file);
 
-	kfree(ctx->hbuf);
+	if (ctx->hbuf)
+		kfree(ctx->hbuf);
 
 	if (ctx->vfsroot)
 		path_put(ctx->vfsroot);
@@ -239,6 +240,7 @@ static struct cr_ctx *cr_ctx_alloc(pid_t
 	if (!ctx)
 		return ERR_PTR(-ENOMEM);
 
+	INIT_LIST_HEAD(&ctx->pgarr_list);
 	ctx->flags = flags;
 
 	err = -EBADF;
@@ -265,8 +267,6 @@ static struct cr_ctx *cr_ctx_alloc(pid_t
 	ctx->vfsroot = &ctx->root_task->fs->root;
 	path_get(ctx->vfsroot);
 
-	INIT_LIST_HEAD(&ctx->pgarr_list);
-
 	ctx->crid = atomic_inc_return(&cr_ctx_count);
 
 	return ctx;

  parent reply	other threads:[~2008-10-23  7:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-21 18:16 External checkpoint patch Dave Hansen
2008-10-21 22:49 ` Oren Laadan
2008-10-21 23:07 ` Oren Laadan
     [not found]   ` <Pine.LNX.4.64.0810211857140.22085-CXF6herHY6ykSYb+qCZC/1i27PF6R63G9nwVQlTi/Pw@public.gmane.org>
2008-10-23  7:51     ` Cedric Le Goater [this message]
2008-10-23 13:48     ` Cedric Le Goater

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=49002CF1.3070505@fr.ibm.com \
    --to=clg-nmtc/0zbporqt0dzr+alfa@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=dave-gkUM19QKKo4@public.gmane.org \
    --cc=orenl-eQaUEPhvms7ENvBUuze7eA@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox