From: Serge Hallyn Date: Thu, 5 Sep 2013 21:56:54 +0000 (-0500) Subject: bdev: free after bdev_init X-Git-Tag: lxc-1.0.0.alpha1~1^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59d66af29da6ca8c5fa8cb63a5bbfc443811bb81;p=thirdparty%2Flxc.git bdev: free after bdev_init (Except in cases where we will immediately exit) Signed-off-by: Serge Hallyn --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index abc2b625a..12d01c2e2 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -1264,9 +1264,12 @@ static int setup_rootfs(struct lxc_conf *conf) // First try mounting rootfs using a bdev struct bdev *bdev = bdev_init(rootfs->path, rootfs->mount, NULL); if (bdev && bdev->ops->mount(bdev) == 0) { + bdev_put(bdev); DEBUG("mounted '%s' on '%s'", rootfs->path, rootfs->mount); return 0; } + if (bdev) + bdev_put(bdev); if (mount_rootfs(rootfs->path, rootfs->mount)) { ERROR("failed to mount rootfs"); return -1; diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index f4d1f8e28..a1a567bc6 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -1511,9 +1511,11 @@ static bool lxcapi_destroy(struct lxc_container *c) r = bdev_init(c->lxc_conf->rootfs.path, c->lxc_conf->rootfs.mount, NULL); if (r) { if (r->ops->destroy(r) < 0) { + bdev_put(r); ERROR("Error destroying rootfs for %s", c->name); goto out; } + bdev_put(r); } mod_all_rdeps(c, false);