From: Christian Brauner Date: Wed, 6 Dec 2017 20:16:38 +0000 (+0100) Subject: coverity: #1425734 X-Git-Tag: lxc-3.0.0.beta1~129^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b9be523370907f21ac6955271e9b4c268621e8c;p=thirdparty%2Flxc.git coverity: #1425734 free memory on error Signed-off-by: Christian Brauner --- diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 413dd375b..3978f87b9 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -4383,7 +4383,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 @@ -4420,21 +4420,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; @@ -4443,6 +4443,7 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd, ret = -EINVAL; } +on_error: if (size < sizeof(*opts)) free(valid_opts);