From b84bcc2da51d6841653ce28e282a5c0b983609a5 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 6 Dec 2017 21:16:38 +0100 Subject: [PATCH] coverity: #1425734 free memory on error Signed-off-by: Christian Brauner --- src/lxc/lxccontainer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index e63660055..8fb158ab2 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -4167,7 +4167,7 @@ WRAP_API_2(bool, lxcapi_detach_interface, const char *, const char *) static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd, struct migrate_opts *opts, unsigned int size) { - int ret; + int ret = -1; struct migrate_opts *valid_opts = opts; /* If the caller has a bigger (newer) struct migrate_opts, let's make @@ -4204,21 +4204,21 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd, case MIGRATE_PRE_DUMP: if (!do_lxcapi_is_running(c)) { ERROR("container is not running"); - return false; + goto on_error; } ret = !__criu_pre_dump(c, valid_opts); break; case MIGRATE_DUMP: if (!do_lxcapi_is_running(c)) { ERROR("container is not running"); - return false; + goto on_error; } ret = !__criu_dump(c, valid_opts); break; case MIGRATE_RESTORE: if (do_lxcapi_is_running(c)) { ERROR("container is already running"); - return false; + goto on_error; } ret = !__criu_restore(c, valid_opts); break; @@ -4227,6 +4227,7 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd, ret = -EINVAL; } +on_error: if (size < sizeof(*opts)) free(valid_opts); -- 2.47.2