]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
bdev: free after bdev_init
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 5 Sep 2013 21:56:54 +0000 (16:56 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 5 Sep 2013 22:04:15 +0000 (17:04 -0500)
(Except in cases where we will immediately exit)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/conf.c
src/lxc/lxccontainer.c

index abc2b625ace4f22f76ec15ef37e77c58a84af03a..12d01c2e29fe701f28b23119be50b4be9c87470b 100644 (file)
@@ -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;
index f4d1f8e2824dc8ca5a7e89d02eb7ffa0fc5623ff..a1a567bc6df2b6e68bfd7e996611649e238b8d7a 100644 (file)
@@ -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);