[lxc-devel] [PATCH 1/3] lxccontainer.c: split up cleate_run_template()
Serge Hallyn
serge.hallyn at ubuntu.com
Wed Oct 8 14:12:06 UTC 2014
Quoting TAMUKI Shoichi (tamuki at linet.gr.jp):
> Hello,
>
> From: Serge Hallyn <serge.hallyn at ubuntu.com>
> Subject: Re: [lxc-devel] [PATCH 1/3] lxccontainer.c: split up cleate_run_template()
> Date: Tue, 7 Oct 2014 22:25:08 +0000
>
> > > Split figureout_rootfs() off from cleate_run_template() to allow
> > > common use of the function.
> >
> > this worries me actually. You'll see why when I ask "who frees the
> > bdev you allocated?"
> >
> > The code you're splitting off was previously only run from within a
> > short-lived task that will exit after the template runs. But by
> > splitting it off into a common function, you have to make sure to
> > not leak memory etc.
> >
> > It's possible that that's the only thing that needs to be cleaned
> > up is to get a strdup() of the bdev->dest, bdev_put(bdev), then
> > return the copy, and require (clearly comment) that callers
> > free the returned string.
> >
> > Oh, no, you'll also have to stop doing exit(1) on failure paths.
>
> The purpose of this patch was just intended to simplify the code in
> create_run_template() which only run from within short-lived task that
> will exit after both the template runs and the password changes.
> So, I just splitted figureout_rootfs() off in a mechanical manner.
>
> Anyway, I agree with you from a viewpoint of strdup() and free().
>
> Ok, I will revise the other patches to fit without this patch later.
No no, I think your patch is fine, it just needs the tweak to free
the bdev.
More information about the lxc-devel
mailing list