]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: #1425734
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 6 Dec 2017 20:16:38 +0000 (21:16 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 15 Dec 2017 12:23:27 +0000 (13:23 +0100)
free memory on error

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/lxccontainer.c

index d47e025cfb2e82502e0b15d45c243d7c3dde8bd5..4b43240d5a401fcfa9549895420c9ea3334fe13d 100644 (file)
@@ -4337,7 +4337,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
@@ -4374,21 +4374,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;
@@ -4397,6 +4397,7 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd,
                ret = -EINVAL;
        }
 
+on_error:
        if (size < sizeof(*opts))
                free(valid_opts);