[lxc-devel] [PATCH 1/7] coverity: Free bdev in clone_update_rootfs
Stéphane Graber
stgraber at ubuntu.com
Wed Feb 12 21:45:50 UTC 2014
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
src/lxc/lxccontainer.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 51e0ac5..a25c196 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -2498,10 +2498,13 @@ static int clone_update_rootfs(struct clone_update_data *data)
if (strcmp(bdev->type, "dir") != 0) {
if (unshare(CLONE_NEWNS) < 0) {
ERROR("error unsharing mounts");
+ bdev_put(bdev);
return -1;
}
- if (bdev->ops->mount(bdev) < 0)
+ if (bdev->ops->mount(bdev) < 0) {
+ bdev_put(bdev);
return -1;
+ }
} else { // TODO come up with a better way
if (bdev->dest)
free(bdev->dest);
@@ -2528,12 +2531,15 @@ static int clone_update_rootfs(struct clone_update_data *data)
if (run_lxc_hooks(c->name, "clone", conf, c->get_config_path(c), hookargs)) {
ERROR("Error executing clone hook for %s", c->name);
+ bdev_put(bdev);
return -1;
}
}
if (!(flags & LXC_CLONE_KEEPNAME)) {
ret = snprintf(path, MAXPATHLEN, "%s/etc/hostname", bdev->dest);
+ bdev_put(bdev);
+
if (ret < 0 || ret >= MAXPATHLEN)
return -1;
if (!file_exists(path))
@@ -2549,6 +2555,9 @@ static int clone_update_rootfs(struct clone_update_data *data)
if (fclose(fout) < 0)
return -1;
}
+ else
+ bdev_put(bdev);
+
return 0;
}
--
1.9.rc1
More information about the lxc-devel
mailing list