Commit 59d66af2 by Serge Hallyn

bdev: free after bdev_init

(Except in cases where we will immediately exit) Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent 41c3b7c7
...@@ -1264,9 +1264,12 @@ static int setup_rootfs(struct lxc_conf *conf) ...@@ -1264,9 +1264,12 @@ static int setup_rootfs(struct lxc_conf *conf)
// First try mounting rootfs using a bdev // First try mounting rootfs using a bdev
struct bdev *bdev = bdev_init(rootfs->path, rootfs->mount, NULL); struct bdev *bdev = bdev_init(rootfs->path, rootfs->mount, NULL);
if (bdev && bdev->ops->mount(bdev) == 0) { if (bdev && bdev->ops->mount(bdev) == 0) {
bdev_put(bdev);
DEBUG("mounted '%s' on '%s'", rootfs->path, rootfs->mount); DEBUG("mounted '%s' on '%s'", rootfs->path, rootfs->mount);
return 0; return 0;
} }
if (bdev)
bdev_put(bdev);
if (mount_rootfs(rootfs->path, rootfs->mount)) { if (mount_rootfs(rootfs->path, rootfs->mount)) {
ERROR("failed to mount rootfs"); ERROR("failed to mount rootfs");
return -1; return -1;
......
...@@ -1511,9 +1511,11 @@ static bool lxcapi_destroy(struct lxc_container *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); r = bdev_init(c->lxc_conf->rootfs.path, c->lxc_conf->rootfs.mount, NULL);
if (r) { if (r) {
if (r->ops->destroy(r) < 0) { if (r->ops->destroy(r) < 0) {
bdev_put(r);
ERROR("Error destroying rootfs for %s", c->name); ERROR("Error destroying rootfs for %s", c->name);
goto out; goto out;
} }
bdev_put(r);
} }
mod_all_rdeps(c, false); mod_all_rdeps(c, false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment